fix(parameter-row): rendering of default/example values of 0 (#6454)
Co-authored-by: @danxmoran
This commit is contained in:
@@ -119,17 +119,26 @@ export default class ParameterRow extends Component {
|
||||
//// Find an initial value
|
||||
|
||||
if (specSelectors.isSwagger2()) {
|
||||
initialValue = paramWithMeta.get("x-example")
|
||||
|| paramWithMeta.getIn(["schema", "example"])
|
||||
|| (schema && schema.getIn(["default"]))
|
||||
initialValue =
|
||||
paramWithMeta.get("x-example") !== undefined
|
||||
? paramWithMeta.get("x-example")
|
||||
: paramWithMeta.getIn(["schema", "example"]) !== undefined
|
||||
? paramWithMeta.getIn(["schema", "example"])
|
||||
: (schema && schema.getIn(["default"]))
|
||||
} else if (specSelectors.isOAS3()) {
|
||||
const currentExampleKey = oas3Selectors.activeExamplesMember(...pathMethod, "parameters", this.getParamKey())
|
||||
initialValue = paramWithMeta.getIn(["examples", currentExampleKey, "value"])
|
||||
|| paramWithMeta.getIn(["content", parameterMediaType, "example"])
|
||||
|| paramWithMeta.get("example")
|
||||
|| (schema && schema.get("example"))
|
||||
|| (schema && schema.get("default"))
|
||||
|| paramWithMeta.get("default") // ensures support for `parameterMacro`
|
||||
initialValue =
|
||||
paramWithMeta.getIn(["examples", currentExampleKey, "value"]) !== undefined
|
||||
? paramWithMeta.getIn(["examples", currentExampleKey, "value"])
|
||||
: paramWithMeta.getIn(["content", parameterMediaType, "example"]) !== undefined
|
||||
? paramWithMeta.getIn(["content", parameterMediaType, "example"])
|
||||
: paramWithMeta.get("example") !== undefined
|
||||
? paramWithMeta.get("example")
|
||||
: (schema && schema.get("example")) !== undefined
|
||||
? (schema && schema.get("example"))
|
||||
: (schema && schema.get("default")) !== undefined
|
||||
? (schema && schema.get("default"))
|
||||
: paramWithMeta.get("default") // ensures support for `parameterMacro`
|
||||
}
|
||||
|
||||
//// Process the initial value
|
||||
|
||||
Reference in New Issue
Block a user