Files
swagger-ui/src/core/components/curl.jsx
Derek Wickern c5a23e584c 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"
2017-06-08 15:59:41 -07:00

29 lines
619 B
JavaScript

import React, { PropTypes } from "react"
import curlify from "core/curlify"
export default class Curl extends React.Component {
static propTypes = {
request: PropTypes.object.isRequired
}
handleFocus(e) {
e.target.select()
document.execCommand("copy")
}
render() {
let { request } = this.props
let curl = curlify(request)
return (
<div>
<h4>Curl</h4>
<div className="copy-paste">
<textarea onFocus={this.handleFocus} readOnly="true" className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
</div>
</div>
)
}
}