Skip to content

Commit fc4a2e3

Browse files
Merge pull request #59 from advanced-rest-client/fix/W-14278539/example-nulleable
Fix/w 14278539/example-nulleable
2 parents 9f0aa95 + cac3b08 commit fc4a2e3

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-example-generator",
33
"description": "Examples generator from AMF model",
4-
"version": "4.4.23",
4+
"version": "4.4.24",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/ExampleGenerator.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1274,7 +1274,20 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
12741274
}
12751275
});
12761276
} else {
1277-
let value = this._computeJsonPropertyValue(range);
1277+
const aKey = this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf);
1278+
let value
1279+
const anyOf = this._ensureArray(range[aKey]);
1280+
if(anyOf){
1281+
for(let anyOfIndex=0; i<anyOf.length; anyOfIndex++) {
1282+
const exampleValue = this._computeJsonPropertyValue(anyOf[anyOfIndex]);
1283+
if(exampleValue!==null){
1284+
value = exampleValue;
1285+
break;
1286+
}
1287+
}
1288+
}else{
1289+
value = this._computeJsonPropertyValue(range);
1290+
}
12781291
if (value === undefined) {
12791292
value = '';
12801293
}

0 commit comments

Comments
 (0)