From 61de35d69cde11336633f9402b14d4e6dc37da69 Mon Sep 17 00:00:00 2001 From: Kyle Shockey Date: Thu, 29 Jun 2017 23:16:54 -0700 Subject: [PATCH] Render request bodies correctly (minus Example Value + editable functionality) --- .../plugins/oas3/components/request-body.jsx | 27 +++++++++---------- .../oas3/wrap-components/parameters.jsx | 16 ++++++++--- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/core/plugins/oas3/components/request-body.jsx b/src/core/plugins/oas3/components/request-body.jsx index d4b58cb7..578eea17 100644 --- a/src/core/plugins/oas3/components/request-body.jsx +++ b/src/core/plugins/oas3/components/request-body.jsx @@ -2,28 +2,25 @@ import React from "react" import { OrderedMap } from "immutable" -export default ({ requestBody, getComponent, specSelectors }) => { +export default ({ requestBody, getComponent, specSelectors, contentType }) => { const Markdown = getComponent("Markdown") - const Model = getComponent("model") + const ModelExample = getComponent("modelExample") const requestBodyDescription = (requestBody && requestBody.get("description")) || null const requestBodyContent = (requestBody && requestBody.get("content")) || new OrderedMap() + contentType = contentType || requestBodyContent.keySeq().first() + + const mediaTypeValue = requestBodyContent.get(contentType) return
{ requestBodyDescription && -

{requestBodyDescription}

- } - { !requestBodyContent.count() ?

No content

: - requestBodyContent.map((mediaTypeValue, key) => ( -
-

{key}

- -
- )).toArray() + } + Not yet implemented}/>
} diff --git a/src/core/plugins/oas3/wrap-components/parameters.jsx b/src/core/plugins/oas3/wrap-components/parameters.jsx index 46831422..3f176bf4 100644 --- a/src/core/plugins/oas3/wrap-components/parameters.jsx +++ b/src/core/plugins/oas3/wrap-components/parameters.jsx @@ -16,7 +16,8 @@ class Parameters extends Component { super(props) this.state = { callbackVisible: false, - parametersVisible: true + parametersVisible: true, + requestBodyContentType: "" } } @@ -94,10 +95,12 @@ class Parameters extends Component { const ParameterRow = getComponent("parameterRow") const TryItOutButton = getComponent("TryItOutButton") + const ContentType = getComponent("contentType") const Callbacks = getComponent("Callbacks", true) const RequestBody = getComponent("RequestBody", true) const isExecute = tryItOutEnabled && allowTryItOut + const { isOAS3 } = specSelectors const requestBody = operation.get("requestBody") return ( @@ -153,13 +156,20 @@ class Parameters extends Component { : "" } { - requestBody && this.state.parametersVisible && + isOAS3() && requestBody && this.state.parametersVisible &&

Request body

+ this.setState({ requestBodyContentType: val })} + className="body-param-content-type" />
- +
}