@api-components/api-type-document 4.2.28 → 4.2.29
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 +3 -3
- package/src/ApiTypeDocument.js +32 -14
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.29",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"module": "index.js",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@advanced-rest-client/arc-marked": "^1.1.0",
|
|
29
29
|
"@advanced-rest-client/markdown-styles": "^3.1.4",
|
|
30
30
|
"@anypoint-web-components/anypoint-button": "^1.2.3",
|
|
31
|
-
"@api-components/amf-helper-mixin": "^4.5.
|
|
31
|
+
"@api-components/amf-helper-mixin": "^4.5.24",
|
|
32
32
|
"@api-components/api-annotation-document": "^4.1.0",
|
|
33
33
|
"@api-components/api-resource-example-document": "^4.3.3",
|
|
34
34
|
"@open-wc/dedupe-mixin": "^1.3.0",
|
|
@@ -99,4 +99,4 @@
|
|
|
99
99
|
"eslint --fix"
|
|
100
100
|
]
|
|
101
101
|
}
|
|
102
|
-
}
|
|
102
|
+
}
|
package/src/ApiTypeDocument.js
CHANGED
|
@@ -560,8 +560,26 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
560
560
|
if (Array.isArray(item)) {
|
|
561
561
|
return item;
|
|
562
562
|
}
|
|
563
|
-
|
|
564
|
-
|
|
563
|
+
|
|
564
|
+
const propertyKey = this._getAmfKey(this.ns.w3.shacl.property);
|
|
565
|
+
const itemProperties = this._ensureArray(item[propertyKey])
|
|
566
|
+
const additionalPropertiesKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema);
|
|
567
|
+
|
|
568
|
+
// If the item doesn't have additional properties, filter the read-only properties and return
|
|
569
|
+
if (!item[additionalPropertiesKey]) {
|
|
570
|
+
return this._filterReadOnlyProperties(itemProperties)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
const additionalPropertiesSchema = this._ensureArray(item[additionalPropertiesKey])
|
|
574
|
+
|
|
575
|
+
// If the item does have additional properties, ensure they are in an array
|
|
576
|
+
const additionalProperties = this._ensureArray(additionalPropertiesSchema[0][propertyKey])
|
|
577
|
+
|
|
578
|
+
// Combine the item's properties and additional properties
|
|
579
|
+
const combinedProperties = [...itemProperties, ...additionalProperties]
|
|
580
|
+
|
|
581
|
+
// Filter the read-only properties and return
|
|
582
|
+
return this._filterReadOnlyProperties(combinedProperties);
|
|
565
583
|
}
|
|
566
584
|
|
|
567
585
|
/**
|
|
@@ -702,7 +720,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
702
720
|
/**
|
|
703
721
|
* @return {TemplateResult} Templates for object properties
|
|
704
722
|
*/
|
|
705
|
-
|
|
723
|
+
_arrayTemplate() {
|
|
706
724
|
const items = this._computeArrayProperties(this._resolvedType) || [];
|
|
707
725
|
const documents = items.map(
|
|
708
726
|
(item) => html`
|
|
@@ -742,9 +760,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
742
760
|
<span>Array of:</span>
|
|
743
761
|
<div class="array-children">
|
|
744
762
|
${documents}
|
|
745
|
-
</div>`
|
|
763
|
+
</div>`
|
|
746
764
|
: html`${documents}`
|
|
747
|
-
|
|
765
|
+
}
|
|
748
766
|
|
|
749
767
|
${this._arrayPropertiesTemplate()}
|
|
750
768
|
`;
|
|
@@ -758,7 +776,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
758
776
|
const selected = this.selectedUnion;
|
|
759
777
|
const selectTypeCallback = this._selectType.bind(this, 'selectedUnion');
|
|
760
778
|
const key = this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf);
|
|
761
|
-
const type = this._computeProperty(this._resolvedType, key,selected);
|
|
779
|
+
const type = this._computeProperty(this._resolvedType, key, selected);
|
|
762
780
|
const typeName = 'union'
|
|
763
781
|
const label = 'Any of'
|
|
764
782
|
return this._multiTypeTemplate({ label, items, typeName, selected, selectTypeCallback, type });
|
|
@@ -855,10 +873,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
855
873
|
}
|
|
856
874
|
return html` ${items.map(
|
|
857
875
|
(item) => html` ${item.label
|
|
858
|
-
|
|
876
|
+
? html`<p class="inheritance-label">
|
|
859
877
|
Properties inherited from <b>${item.label}</b>.
|
|
860
878
|
</p>`
|
|
861
|
-
|
|
879
|
+
: html`<p class="inheritance-label">Properties defined inline.</p>`}
|
|
862
880
|
<api-type-document
|
|
863
881
|
class="and-document"
|
|
864
882
|
.amf="${this.amf}"
|
|
@@ -887,12 +905,12 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
887
905
|
return html`<style>${this.styles}</style>
|
|
888
906
|
<section class="examples" ?hidden="${!this._renderMainExample}">
|
|
889
907
|
${this.shouldRenderMediaSelector
|
|
890
|
-
|
|
908
|
+
? html`<div class="media-type-selector">
|
|
891
909
|
<span>Media type:</span>
|
|
892
910
|
${mediaTypes.map((item, index) => {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
911
|
+
const selected = this.selectedMediaType === index;
|
|
912
|
+
const pressed = selected ? 'true' : 'false';
|
|
913
|
+
return html`<anypoint-button
|
|
896
914
|
part="content-action-button"
|
|
897
915
|
class="media-toggle"
|
|
898
916
|
data-index="${index}"
|
|
@@ -903,9 +921,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
|
|
|
903
921
|
title="Select ${item} media type"
|
|
904
922
|
>${item}</anypoint-button
|
|
905
923
|
>`;
|
|
906
|
-
|
|
924
|
+
})}
|
|
907
925
|
</div>`
|
|
908
|
-
|
|
926
|
+
: ''}
|
|
909
927
|
|
|
910
928
|
<api-resource-example-document
|
|
911
929
|
.amf="${this.amf}"
|