Skip to content

Commit

Permalink
Merge pull request #64 from advanced-rest-client/fix/W-14874965/-swag…
Browse files Browse the repository at this point in the history
…ger-Json-file-not-displaying-valid-Json-examples-in-response-in-Design-center-and-Exchange

[W-14874965] Swagger-Json-file-not-displaying-valid-Json-examples-in-response-in-Design-center-and-Exchange
  • Loading branch information
alexpmule authored Jan 31, 2024
2 parents 2866595 + 77fc0fe commit ecbd8c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@api-components/api-example-generator",
"description": "Examples generator from AMF model",
"version": "4.4.27",
"version": "4.4.28",
"license": "Apache-2.0",
"main": "index.js",
"module": "index.js",
Expand All @@ -26,7 +26,7 @@
"email": "[email protected]"
},
"dependencies": {
"@api-components/amf-helper-mixin": "^4.1.8",
"@api-components/amf-helper-mixin": "^4.5.24",
"lit-element": "^2.4.0"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/ExampleGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1635,9 +1635,17 @@ export class ExampleGenerator extends AmfHelperMixin(Object) {
_computeJsonObjectValue(range) {
const pKey = this._getAmfKey(this.ns.w3.shacl.property);
const properties = this._ensureArray(range[pKey]);

const additionalPropertiesKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema);
const additionalProperties = this._ensureArray(range[additionalPropertiesKey]);

if (properties && properties.length) {
return this._jsonExampleFromProperties(properties);
}
if (additionalProperties && additionalProperties.length) {
return this._jsonExampleFromProperties(this._ensureArray(additionalProperties[0][pKey]));
}

return {};
}

Expand Down

0 comments on commit ecbd8c5

Please sign in to comment.