fix(validateParam): validate JSON parameter values + support Parameter.content (#5657)

* improve(getParameterSchema): ParameterSchemaDescriptor pattern

* chore: update usage of `getParameterSchema`

* consider `Parameter.content` media type when validating JSON values
This commit is contained in:
kyle
2019-10-11 11:20:23 -07:00
committed by GitHub
parent 71a17f801e
commit 75a0e5d5dc
5 changed files with 190 additions and 51 deletions

View File

@@ -41,7 +41,7 @@ export default class ParameterRow extends Component {
let enumValue
if(isOAS3) {
let schema = getParameterSchema(parameterWithMeta, { isOAS3 })
let { schema } = getParameterSchema(parameterWithMeta, { isOAS3 })
enumValue = schema.get("enum")
} else {
enumValue = parameterWithMeta ? parameterWithMeta.get("enum") : undefined
@@ -98,7 +98,7 @@ export default class ParameterRow extends Component {
const paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
const schema = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() })
const { schema } = getParameterSchema(paramWithMeta, { isOAS3: specSelectors.isOAS3() })
const parameterMediaType = paramWithMeta
.get("content", Map())
@@ -209,9 +209,10 @@ export default class ParameterRow extends Component {
const ExamplesSelectValueRetainer = getComponent("ExamplesSelectValueRetainer")
const Example = getComponent("Example")
let { schema } = getParameterSchema(param, { isOAS3 })
let paramWithMeta = specSelectors.parameterWithMetaByIdentity(pathMethod, rawParam) || Map()
let format = param.get("format")
let schema = getParameterSchema(param, { isOAS3 })
let type = schema.get("type")
let isFormData = inType === "formData"
let isFormDataSupported = "FormData" in win