Skip to content

Commit c0fec9b

Browse files
authored
Merge pull request #72 from advanced-rest-client/fix/W-12428173/type-recursion
[W-12428173] Type recursion
2 parents eee91f6 + cf01c34 commit c0fec9b

File tree

9 files changed

+6008
-5102
lines changed

9 files changed

+6008
-5102
lines changed

demo/W-12428173/W-12428173.raml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#%RAML 1.0 Library
2+
usage:
3+
4+
# see https://canda.leanix.net/canda/factsheet/DataObject/ad2b18a7-e768-411d-af15-f0fa5df689cd
5+
6+
types:
7+
valueAddedServiceMapping:
8+
type: !include ref/value-added-service-mapping-schema.json
9+
example: !include ref/value-added-service-mapping-example.json
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"seasVasLocation" : "SEAS"
3+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema",
3+
"description": "Represents data from MPTH70 Value Added Service Mapping For SAP ERP",
4+
"type": "object",
5+
"properties": {
6+
"seasVasLocation": {
7+
"type": "string",
8+
"description": "VAS Location in case of SEAS where this Value added service will be executed. @since 2023.1",
9+
"see" : "https://canda-services.atlassian.net/browse/CARA-75",
10+
"anyOf" : [
11+
{
12+
"type": "string",
13+
"enum": [ "SEAS", "DC" ]
14+
},
15+
{
16+
"type": "string",
17+
"description" : "accept any unknown value to be extendable",
18+
"see" : "https://canda-services.atlassian.net/wiki/spaces/IETKB/pages/1390149835/Web+API+Guideline#Versioning"
19+
}
20+
]
21+
}
22+
}
23+
}

demo/apis.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"array-type/array-type.raml": "RAML 1.0",
1717
"W-11858334/W-11858334.raml": "RAML 1.0",
1818
"W-12137562/W-12137562.raml": "RAML 1.0",
19+
"W-12428173/W-12428173.raml": "RAML 1.0",
1920
"APIC-429/APIC-429.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },
2021
"SE-17897/SE-17897.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },
2122
"new-oas3-types/new-oas3-types.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },

demo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class ApiDemo extends ApiDemoPage {
115115
['array-type', 'array-type'],
116116
['W-11858334', 'W-11858334'],
117117
['W-12137562', 'W-12137562'],
118+
['W-12428173', 'W-12428173'],
118119
].map(
119120
([file, label]) => html` <anypoint-item data-src="${file}-compact.json"
120121
>${label} - compact model</anypoint-item

package-lock.json

Lines changed: 5917 additions & 5100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-type-document",
33
"description": "A documentation table for type (resource) properties. Works with AMF data model",
4-
"version": "4.2.22",
4+
"version": "4.2.23",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",
@@ -45,7 +45,7 @@
4545
"@open-wc/testing": "^2.5.15",
4646
"@web/dev-server": "^0.1.24",
4747
"@web/test-runner": "^0.13.18",
48-
"@web/test-runner-playwright": "^0.8.8",
48+
"@web/test-runner-playwright": "0.8.10",
4949
"eslint": "^7.32.0",
5050
"eslint-config-prettier": "^8.1.0",
5151
"husky": "^7.0.2",

src/ApiTypeDocument.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,11 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
388388
isOneOf = true;
389389
key = this._getAmfKey(this.ns.w3.shacl.xone);
390390
this.oneOfTypes = this._computeTypes(type, key);
391+
} else if (this._hasProperty(type, this.ns.w3.shacl.or)) {
392+
isScalar = false;
393+
isAnyOf = true;
394+
key = this._getAmfKey(this.ns.w3.shacl.or);
395+
this.anyOfTypes = this._computeTypes(type, key);
391396
}
392397
} else if (
393398
this._hasType(type, this.ns.aml.vocabularies.shapes.UnionShape)

test/W-12428173.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* eslint-disable prefer-destructuring */
2+
import {fixture, assert, aTimeout} from '@open-wc/testing'
3+
import { AmfLoader } from './amf-loader.js';
4+
import '../api-type-document.js';
5+
6+
/** @typedef {import('..').ApiTypeDocument} ApiTypeDocument */
7+
/** @typedef {import('..').PropertyShapeDocument} PropertyShapeDocument */
8+
/** @typedef {import('@api-components/amf-helper-mixin').AmfDocument} AmfDocument */
9+
10+
describe('<api-type-document>', () => {
11+
const file = 'W-12428173';
12+
13+
/**
14+
* @returns {Promise<ApiTypeDocument>}
15+
*/
16+
async function basicFixture() {
17+
return fixture(`<api-type-document></api-type-document>`);
18+
}
19+
20+
[
21+
['Regular model', false],
22+
['Compact model', true],
23+
].forEach((item) => {
24+
describe(String(item[0]), () => {
25+
let element = /** @type ApiTypeDocument */ (null);
26+
beforeEach(async () => {
27+
element = await basicFixture();
28+
});
29+
30+
it('renders complex element', async () => {
31+
const data = await AmfLoader.loadType('valueAddedServiceMapping', item[1], file);
32+
element.amf = data[0];
33+
element.type = data[1];
34+
await aTimeout(0);
35+
36+
const shape = element.shadowRoot.querySelector('property-shape-document')
37+
assert.ok(shape);
38+
39+
/** @type HTMLElement */ (shape.shadowRoot.querySelector('.complex-toggle')).click();
40+
await aTimeout(0);
41+
await aTimeout(0);
42+
43+
assert.ok(shape.shadowRoot.querySelector('api-type-document.children.complex'));
44+
});
45+
});
46+
});
47+
});

0 commit comments

Comments
 (0)