feature: read the x-example field and use them as values (#3538)
* Read the x-example field and use them as values Allow to show the value defined in the "x-example" field when pressing try-out. The "default" value will have the precedence over the x-example * Use `parameterWithMeta` to get parameter data in <ParameterRow> * Prefer specPath when fetching resolved subtrees in OperationContainer * Add test for OAS3 callback rendering * Remove debugger statement * Pass base resolution URL directly to Swagger-Client subtree resolver * Remove accidental comment * Migrate additional options * Don't default to empty Map when getting subtree * make "default" and "x-example" mutually exclusive "x-example" wins when both are present * limit "x-example" to non-body parameters
This commit is contained in:
@@ -24,11 +24,18 @@ export default class ParameterRow extends Component {
|
|||||||
|
|
||||||
let { specSelectors, pathMethod, param } = props
|
let { specSelectors, pathMethod, param } = props
|
||||||
let defaultValue = param.get("default")
|
let defaultValue = param.get("default")
|
||||||
|
let xExampleValue = param.get("x-example")
|
||||||
let parameter = specSelectors.parameterWithMeta(pathMethod, param.get("name"), param.get("in"))
|
let parameter = specSelectors.parameterWithMeta(pathMethod, param.get("name"), param.get("in"))
|
||||||
let value = parameter ? parameter.get("value") : ""
|
let value = parameter ? parameter.get("value") : ""
|
||||||
if ( defaultValue !== undefined && value === undefined ) {
|
|
||||||
this.onChangeWrapper(defaultValue)
|
if( param.get("in") !== "body" ) {
|
||||||
|
if ( xExampleValue !== undefined && value === undefined ) {
|
||||||
|
this.onChangeWrapper(xExampleValue)
|
||||||
|
} else if ( defaultValue !== undefined && value === undefined ) {
|
||||||
|
this.onChangeWrapper(defaultValue)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(props) {
|
componentWillReceiveProps(props) {
|
||||||
|
|||||||
Reference in New Issue
Block a user