diff --git a/src/core/components/content-type.jsx b/src/core/components/content-type.jsx
index 1afffd33..80f75041 100644
--- a/src/core/components/content-type.jsx
+++ b/src/core/components/content-type.jsx
@@ -7,7 +7,7 @@ const noop = ()=>{}
export default class ContentType extends React.Component {
static propTypes = {
- contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set]),
+ contentTypes: PropTypes.oneOfType([ImPropTypes.list, ImPropTypes.set, ImPropTypes.seq]),
value: PropTypes.string,
onChange: PropTypes.func,
className: PropTypes.string
@@ -21,7 +21,9 @@ export default class ContentType extends React.Component {
componentDidMount() {
// Needed to populate the form, initially
- this.props.onChange(this.props.contentTypes.first())
+ if(this.props.contentTypes) {
+ this.props.onChange(this.props.contentTypes.first())
+ }
}
onChangeWrapper = e => this.props.onChange(e.target.value)
diff --git a/src/core/components/model-example.jsx b/src/core/components/model-example.jsx
index 0117c9a5..c3af443f 100644
--- a/src/core/components/model-example.jsx
+++ b/src/core/components/model-example.jsx
@@ -35,9 +35,9 @@ export default class ModelExample extends React.Component {
Example Value
-
+ { schema ?
Model
-
+ : null }
{
diff --git a/src/core/components/response.jsx b/src/core/components/response.jsx
index 67b5b969..58b54684 100644
--- a/src/core/components/response.jsx
+++ b/src/core/components/response.jsx
@@ -1,5 +1,5 @@
import React, { PropTypes } from "react"
-import { fromJS } from "immutable"
+import { fromJS, Seq } from "immutable"
import { getSampleSchema } from "core/utils"
const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
@@ -28,6 +28,13 @@ const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => {
}
export default class Response extends React.Component {
+ constructor(props, context) {
+ super(props, context)
+
+ this.state = {
+ responseContentType: ""
+ }
+ }
static propTypes = {
code: PropTypes.string.isRequired,
@@ -56,8 +63,8 @@ export default class Response extends React.Component {
} = this.props
let { inferSchema } = fn
+ let { isOAS3 } = specSelectors
- let schema = inferSchema(response.toJS())
let headers = response.get("headers")
let examples = response.get("examples")
let links = response.get("links")
@@ -66,14 +73,17 @@ export default class Response extends React.Component {
const ModelExample = getComponent("modelExample")
const Markdown = getComponent( "Markdown" )
const OperationLink = getComponent("operationLink")
+ const ContentType = getComponent("contentType")
var sampleResponse
- if(specSelectors.isOAS3()) {
- let oas3SchemaForContentType = response.getIn(["content", contentType, "schema"])
- sampleResponse = oas3SchemaForContentType ? getSampleSchema(oas3SchemaForContentType, contentType, { includeReadOnly: true }) : null
+ if(isOAS3()) {
+ let oas3SchemaForContentType = response.getIn(["content", this.state.responseContentType, "schema"])
+ sampleResponse = oas3SchemaForContentType ? getSampleSchema(oas3SchemaForContentType.toJS(), this.state.responseContentType, { includeReadOnly: true }) : null
+ var schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null
} else {
sampleResponse = schema ? getSampleSchema(schema, contentType, { includeReadOnly: true }) : null
+ var schema = inferSchema(response.toJS())
}
let example = getExampleComponent( sampleResponse, examples, HighlightCode )
@@ -88,6 +98,12 @@ export default class Response extends React.Component {
+ { isOAS3 ? this.setState({ responseContentType: val })}
+ className="response-content-type" /> : null }
+
{ example ? (