@api-components/api-type-document 4.2.24 → 4.2.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/ApiTypeDocument.js +20 -10
- package/src/PropertyShapeDocument.js +11 -4
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@api-components/api-type-document",
|
|
3
3
|
"description": "A documentation table for type (resource) properties. Works with AMF data model",
|
|
4
|
-
"version": "4.2.
|
|
4
|
+
"version": "4.2.27",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
package/src/ApiTypeDocument.js
CHANGED
|
@@ -376,12 +376,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
376
376
|
let isOneOf = false;
|
|
377
377
|
let isAnyOf = false;
|
|
378
378
|
let key = ''
|
|
379
|
+
const shapesKey = this.ns.aml.vocabularies.shapes
|
|
379
380
|
if (type instanceof Array) {
|
|
380
381
|
isObject = true;
|
|
381
|
-
} else if (
|
|
382
|
-
this._hasType(type, this.ns.aml.vocabularies.shapes.ScalarShape) ||
|
|
383
|
-
this._hasType(type, this.ns.aml.vocabularies.shapes.NilShape)
|
|
384
|
-
) {
|
|
382
|
+
} else if (this._hasType(type, shapesKey.ScalarShape) || this._hasType(type, shapesKey.NilShape)) {
|
|
385
383
|
isScalar = true;
|
|
386
384
|
if (this._hasProperty(type, this.ns.w3.shacl.xone)) {
|
|
387
385
|
isScalar = false;
|
|
@@ -395,10 +393,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
395
393
|
this.anyOfTypes = this._computeTypes(type, key);
|
|
396
394
|
}
|
|
397
395
|
} else if (
|
|
398
|
-
this._hasType(type,
|
|
396
|
+
this._hasType(type, shapesKey.UnionShape)
|
|
399
397
|
) {
|
|
400
398
|
isUnion = true;
|
|
401
|
-
key = this._getAmfKey(
|
|
399
|
+
key = this._getAmfKey(shapesKey.anyOf);
|
|
402
400
|
this.unionTypes = this._computeTypes(type, key);
|
|
403
401
|
} else if (this._hasProperty(type, this.ns.w3.shacl.xone)) {
|
|
404
402
|
isOneOf = true;
|
|
@@ -409,18 +407,23 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
409
407
|
key = this._getAmfKey(this.ns.w3.shacl.or);
|
|
410
408
|
this.anyOfTypes = this._computeTypes(type, key);
|
|
411
409
|
} else if (
|
|
412
|
-
this._hasType(type,
|
|
410
|
+
this._hasType(type, shapesKey.ArrayShape)
|
|
413
411
|
) {
|
|
414
412
|
isArray = true;
|
|
415
|
-
const iKey = this._getAmfKey(
|
|
413
|
+
const iKey = this._getAmfKey(shapesKey.items);
|
|
416
414
|
let items = this._ensureArray(type[iKey]);
|
|
417
415
|
if (items) {
|
|
418
416
|
items = items[0];
|
|
419
417
|
const andKey = this._getAmfKey(this.ns.w3.shacl.and);
|
|
418
|
+
const orKey = this._getAmfKey(this.ns.w3.shacl.or);
|
|
420
419
|
if (andKey in items) {
|
|
421
420
|
isArray = false;
|
|
422
421
|
isAnd = true;
|
|
423
422
|
this.andTypes = this._computeAndTypes(items[andKey]);
|
|
423
|
+
} else if (orKey in items) {
|
|
424
|
+
isArray = false;
|
|
425
|
+
isAnyOf = true;
|
|
426
|
+
this.anyOfTypes = this._computeAndTypes(items[orKey]);
|
|
424
427
|
}
|
|
425
428
|
}
|
|
426
429
|
} else if (this._hasType(type, this.ns.w3.shacl.NodeShape)) {
|
|
@@ -434,7 +437,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
434
437
|
isAnd = true;
|
|
435
438
|
this.andTypes = this._computeAndTypes(type[andKey]);
|
|
436
439
|
}
|
|
437
|
-
} else if (this._hasType(type,
|
|
440
|
+
} else if (this._hasType(type, shapesKey.AnyShape)) {
|
|
438
441
|
const andKey = this._getAmfKey(this.ns.w3.shacl.and);
|
|
439
442
|
if (andKey in type) {
|
|
440
443
|
isAnd = true;
|
|
@@ -782,7 +785,14 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
782
785
|
const selected = this.selectedAnyOf;
|
|
783
786
|
const selectTypeCallback = this._selectType.bind(this, 'selectedAnyOf');
|
|
784
787
|
const key = this._getAmfKey(this.ns.w3.shacl.or);
|
|
785
|
-
|
|
788
|
+
let type = this._computeProperty(this._resolvedType, key, selected);
|
|
789
|
+
if (!type) {
|
|
790
|
+
const itemsKey = this._getAmfKey(this.ns.aml.vocabularies.shapes.items);
|
|
791
|
+
const items = this._ensureArray(this._resolvedType[itemsKey]);
|
|
792
|
+
if (items.length > 0) {
|
|
793
|
+
type = this._computeProperty(items[0], key, selected);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
786
796
|
return this._multiTypeTemplate({ label, items, typeName, selected, selectTypeCallback, type });
|
|
787
797
|
}
|
|
788
798
|
|
|
@@ -295,8 +295,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
295
295
|
this.propertyName
|
|
296
296
|
);
|
|
297
297
|
this.propertyDataType = this._computeObjectDataType(range, shape);
|
|
298
|
-
|
|
299
|
-
this.deprecated = isDeprecated;
|
|
298
|
+
this.deprecated = Boolean(this._computeIsDeprecated(range));
|
|
300
299
|
}
|
|
301
300
|
|
|
302
301
|
_computeIsDeprecated(range) {
|
|
@@ -391,6 +390,13 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
391
390
|
return !!parentTypeName;
|
|
392
391
|
}
|
|
393
392
|
|
|
393
|
+
_toBoolean(value) {
|
|
394
|
+
if (typeof value === 'boolean') {
|
|
395
|
+
return value
|
|
396
|
+
}
|
|
397
|
+
return value === 'true'
|
|
398
|
+
}
|
|
399
|
+
|
|
394
400
|
/**
|
|
395
401
|
* Computes value for `isRequired` property.
|
|
396
402
|
* In AMF model a property is required when `http://www.w3.org/ns/shacl#minCount`
|
|
@@ -405,10 +411,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
405
411
|
}
|
|
406
412
|
shape = this._resolve(shape);
|
|
407
413
|
if (this._hasType(shape, this.ns.aml.vocabularies.apiContract.Parameter)) {
|
|
408
|
-
|
|
414
|
+
const required = this._getValue(
|
|
409
415
|
shape,
|
|
410
416
|
this.ns.aml.vocabularies.apiContract.required
|
|
411
|
-
)
|
|
417
|
+
)
|
|
418
|
+
return this._toBoolean(required);
|
|
412
419
|
}
|
|
413
420
|
const data = this._getValue(shape, this.ns.w3.shacl.minCount);
|
|
414
421
|
return data !== undefined && Number(data) !== 0;
|