Skip to content

Commit 4900b11

Browse files
dawezshockey
authored andcommitted
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
1 parent b13b05e commit 4900b11

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/core/components/parameter-row.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,18 @@ export default class ParameterRow extends Component {
2424

2525
let { specSelectors, pathMethod, param } = props
2626
let defaultValue = param.get("default")
27+
let xExampleValue = param.get("x-example")
2728
let parameter = specSelectors.parameterWithMeta(pathMethod, param.get("name"), param.get("in"))
2829
let value = parameter ? parameter.get("value") : ""
29-
if ( defaultValue !== undefined && value === undefined ) {
30-
this.onChangeWrapper(defaultValue)
30+
31+
if( param.get("in") !== "body" ) {
32+
if ( xExampleValue !== undefined && value === undefined ) {
33+
this.onChangeWrapper(xExampleValue)
34+
} else if ( defaultValue !== undefined && value === undefined ) {
35+
this.onChangeWrapper(defaultValue)
36+
}
3137
}
38+
3239
}
3340

3441
componentWillReceiveProps(props) {

0 commit comments

Comments
 (0)