fix(parameters): allowedValues for enum and boolean types (#8231)

* Change parameter with empty map

* Change allowValues data type

Co-authored-by: Tim Lai <timothy.lai@smartbear.com>
This commit is contained in:
ishuen
2022-10-26 02:01:07 +08:00
committed by GitHub
parent 99ef4b9945
commit 2a967e9b25
3 changed files with 36 additions and 4 deletions

View File

@@ -85,7 +85,7 @@ export class JsonSchema_string extends Component {
const Select = getComponent("Select")
return (<Select className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
allowedValues={ enumValue }
allowedValues={ [...enumValue] }
value={ value }
allowEmptyValue={ !required }
disabled={disabled}
@@ -335,14 +335,14 @@ export class JsonSchema_boolean extends Component {
errors = errors.toJS ? errors.toJS() : []
let enumValue = schema && schema.get ? schema.get("enum") : null
let allowEmptyValue = !enumValue || !required
let booleanValue = !enumValue && fromJS(["true", "false"])
let booleanValue = !enumValue && ["true", "false"]
const Select = getComponent("Select")
return (<Select className={ errors.length ? "invalid" : ""}
title={ errors.length ? errors : ""}
value={ String(value) }
disabled={ disabled }
allowedValues={ enumValue || booleanValue }
allowedValues={ enumValue ? [...enumValue] : booleanValue }
allowEmptyValue={ allowEmptyValue }
onChange={ this.onEnumChange }/>)
}

View File

@@ -86,7 +86,7 @@ export default function getParameterSchema(parameter, { isOAS3 } = {}) {
}
return {
schema: parameter.get("schema", Im.Map()),
schema: parameter.get("schema") ? parameter.get("schema", Im.Map()): Im.Map(),
parameterContentMediaType: null,
}
}