Skip to content

Commit ba5b807

Browse files
authored
[W-13079436] Error: "The API file specifies body for this request but it does not specify the data model." occurs when keyword oneOf used in JSON schema (#55)
* chore: add type xone * chore: fix unit test * 4.4.8
1 parent eaaa4ca commit ba5b807

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
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-body-document",
33
"description": "A component to render HTTP method body documentation based on AMF model",
4-
"version": "4.4.7",
4+
"version": "4.4.8",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/ApiBodyDocumentElement.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
426426
let isAnyType = false;
427427
let isAnd = false;
428428
let isOr = false;
429+
let isXone = false;
429430
const types = body && body['@type'];
430431
if (types) {
431432
if (types.indexOf(this._getAmfKey(this.ns.w3.shacl.NodeShape)) > -1 ||
@@ -439,16 +440,19 @@ export class ApiBodyDocumentElement extends AmfHelperMixin(LitElement) {
439440
} else if (types.indexOf(this._getAmfKey(this.ns.aml.vocabularies.shapes.AnyShape)) > -1) {
440441
const andKey = this._getAmfKey(this.ns.w3.shacl.and);
441442
const orKey = this._getAmfKey(this.ns.w3.shacl.or);
443+
const xoneKey = this._getAmfKey(this.ns.w3.shacl.xone);
442444
if (andKey in body) {
443445
isAnd = true;
444446
} else if (orKey in body) {
445447
isOr = true;
448+
} else if (xoneKey in body) {
449+
isXone = true;
446450
}else {
447451
isAnyType = true;
448452
}
449453
}
450454
}
451-
this._isObject = isObject || isAnd || isOr;
455+
this._isObject = isObject || isAnd || isOr || isXone;
452456
this._isSchema = isSchema;
453457
this._isAnyType = isAnyType;
454458
}

test/api-body-document.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ describe('ApiBodyDocumentElement', () => {
498498
assert.lengthOf(node.renderedExamples, 1, 'Examples render has 1 example');
499499
assert.equal(node.renderedExamples[0].title, '400_badrequest_validate_customer_account_hash');
500500
done();
501-
}, 120);
501+
}, 500);
502502
});
503503
});
504504
});

0 commit comments

Comments
 (0)