Fix #2922: file uploads fail to render curl command

The request body is an immutable.js OrderedMap rather than a string,
so this fixes the type error:

  TypeError: request.get(...).split is not a function

Adds a special curl command argument for files, e.g.

  curl -F "param=value" -F "file=@filename.txt;type=text/plain"
This commit is contained in:
Derek Wickern
2017-06-08 15:17:27 -07:00
parent f6e921f101
commit c5a23e584c
5 changed files with 41 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ import _memoize from "lodash/memoize"
import some from "lodash/some"
import eq from "lodash/eq"
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
import win from "./window"
const DEFAULT_REPONSE_KEY = "default"
@@ -34,6 +35,9 @@ export function fromJSOrdered (js) {
if(isImmutable(js))
return js // Can't do much here
if (js instanceof win.File)
return js
return !isObject(js) ? js :
Array.isArray(js) ?
Im.Seq(js).map(fromJSOrdered).toList() :