|
1 | 1 | import React, { Component } from "react"
|
2 |
| -import { Map, List } from "immutable" |
| 2 | +import { Map, List, fromJS } from "immutable" |
3 | 3 | import PropTypes from "prop-types"
|
4 | 4 | import ImPropTypes from "react-immutable-proptypes"
|
5 | 5 | import win from "core/window"
|
@@ -97,7 +97,7 @@ export default class ParameterRow extends Component {
|
97 | 97 | let { specSelectors, pathMethod, rawParam, oas3Selectors, fn } = this.props
|
98 | 98 |
|
99 | 99 | const paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
|
100 |
| - const { schema } = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() }) |
| 100 | + let { schema } = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() }) |
101 | 101 | const parameterMediaType = paramWithMeta
|
102 | 102 | .get("content", Map())
|
103 | 103 | .keySeq()
|
@@ -126,6 +126,8 @@ export default class ParameterRow extends Component {
|
126 | 126 | ? paramWithMeta.getIn(["schema", "example"])
|
127 | 127 | : (schema && schema.getIn(["default"]))
|
128 | 128 | } else if (specSelectors.isOAS3()) {
|
| 129 | + schema = this.composeJsonSchema(schema) |
| 130 | + |
129 | 131 | const currentExampleKey = oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
|
130 | 132 | initialValue =
|
131 | 133 | paramWithMeta.getIn(["examples", currentExampleKey, "value"]) !== undefined
|
@@ -181,6 +183,13 @@ export default class ParameterRow extends Component {
|
181 | 183 | return `${param.get("name")}-${param.get("in")}`
|
182 | 184 | }
|
183 | 185 |
|
| 186 | + composeJsonSchema(schema) { |
| 187 | + const { fn } = this.props |
| 188 | + const oneOf = schema.get("oneOf")?.get(0)?.toJS() |
| 189 | + const anyOf = schema.get("anyOf")?.get(0)?.toJS() |
| 190 | + return fromJS(fn.mergeJsonSchema(schema.toJS(), oneOf ?? anyOf ?? {})) |
| 191 | + } |
| 192 | + |
184 | 193 | render() {
|
185 | 194 | let {param, rawParam, getComponent, getConfigs, isExecute, fn, onChangeConsumes, specSelectors, pathMethod, specPath, oas3Selectors} = this.props
|
186 | 195 |
|
@@ -222,6 +231,10 @@ export default class ParameterRow extends Component {
|
222 | 231 | let { schema } = getParameterSchema(param, { isOAS3 })
|
223 | 232 | let paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
|
224 | 233 |
|
| 234 | + if (isOAS3) { |
| 235 | + schema = this.composeJsonSchema(schema) |
| 236 | + } |
| 237 | + |
225 | 238 | let format = schema ? schema.get("format") : null
|
226 | 239 | let type = schema ? schema.get("type") : null
|
227 | 240 | let itemType = schema ? schema.getIn(["items", "type"]) : null
|
|
0 commit comments