Skip to content

Commit 583c4fb

Browse files
authored
fix: correct spec paths for parameters, responses and request bodies (#10609)
1 parent 0422415 commit 583c4fb

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

src/core/components/parameter-row.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,10 @@ export default class ParameterRow extends Component {
247247

248248
let { schema } = getParameterSchema(param, { isOAS3 })
249249
let paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
250+
const parameterMediaType = paramWithMeta
251+
.get("content", Map())
252+
.keySeq()
253+
.first()
250254

251255
if (isOAS3) {
252256
schema = this.composeJsonSchema(schema)
@@ -373,7 +377,11 @@ export default class ParameterRow extends Component {
373377
{ (isObject || isArrayOfObjects) ? (
374378
<ModelExample
375379
getComponent={getComponent}
376-
specPath={specPath.push("schema")}
380+
specPath={
381+
parameterMediaType
382+
? specPath.push("content", parameterMediaType, "schema")
383+
: specPath.push("schema")
384+
}
377385
getConfigs={getConfigs}
378386
isExecute={isExecute}
379387
specSelectors={specSelectors}

src/core/components/response.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import PropTypes from "prop-types"
33
import ImPropTypes from "react-immutable-proptypes"
44
import cx from "classnames"
5-
import { fromJS, Seq, Iterable, List, Map } from "immutable"
5+
import { fromJS, Seq, Iterable, Map } from "immutable"
66
import { getExtensions, fromJSOrdered, stringify } from "core/utils"
77
import { getKnownSyntaxHighlighterLanguage } from "core/utils/jsonParse"
88

@@ -118,7 +118,9 @@ export default class Response extends React.Component {
118118
const oas3SchemaForContentType = activeMediaType.get("schema")
119119

120120
schema = oas3SchemaForContentType ? inferSchema(oas3SchemaForContentType.toJS()) : null
121-
specPathWithPossibleSchema = oas3SchemaForContentType ? List(["content", this.state.responseContentType, "schema"]) : specPath
121+
specPathWithPossibleSchema = oas3SchemaForContentType
122+
? specPath.push("content", this.state.responseContentType, "schema")
123+
: specPath
122124
} else {
123125
schema = response.get("schema")
124126
specPathWithPossibleSchema = response.has("schema") ? specPath.push("schema") : specPath

src/core/plugins/oas3/components/request-body.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ const RequestBody = ({
298298
expandDepth={1}
299299
isExecute={isExecute}
300300
schema={mediaTypeValue.get("schema")}
301-
specPath={specPath.push("content", contentType)}
301+
specPath={specPath.push("content", contentType, "schema")}
302302
example={example}
303303
includeWriteOnly={true}
304304
/>

0 commit comments

Comments
 (0)