fix(parameter-row): rendering of default/example values of 0 (#6454)

Co-authored-by: @danxmoran
This commit is contained in:
Tim Lai
2020-10-01 16:28:55 -07:00
committed by GitHub
parent db2cca8e86
commit 797929f1cf
2 changed files with 158 additions and 10 deletions

View File

@@ -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