From 4900b11079f5b5d2eb671b1d81deeb75f5166b5a Mon Sep 17 00:00:00 2001 From: Davide Zipeto Date: Sat, 3 Mar 2018 03:31:08 +0100 Subject: [PATCH] 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 * 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 --- src/core/components/parameter-row.jsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/core/components/parameter-row.jsx b/src/core/components/parameter-row.jsx index 46c5590d..33aa31ea 100644 --- a/src/core/components/parameter-row.jsx +++ b/src/core/components/parameter-row.jsx @@ -24,11 +24,18 @@ export default class ParameterRow extends Component { let { specSelectors, pathMethod, param } = props let defaultValue = param.get("default") + let xExampleValue = param.get("x-example") let parameter = specSelectors.parameterWithMeta(pathMethod, param.get("name"), param.get("in")) 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) {