@api-components/api-type-document 4.2.27 → 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 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.27",
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.6",
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
+ }
@@ -174,6 +174,8 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
174
174
  */
175
175
  noMediaSelector: boolean;
176
176
 
177
+ noArrayInfo: boolean;
178
+
177
179
  get shouldRenderMediaSelector(): boolean;
178
180
 
179
181
  constructor();
@@ -167,6 +167,8 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
167
167
  * applicable.
168
168
  */
169
169
  noMediaSelector: { type: Boolean },
170
+
171
+ noArrayInfo: { type: Boolean },
170
172
  };
171
173
  }
172
174
 
@@ -558,8 +560,26 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
558
560
  if (Array.isArray(item)) {
559
561
  return item;
560
562
  }
561
- const key = this._getAmfKey(this.ns.w3.shacl.property);
562
- return this._filterReadOnlyProperties(this._ensureArray(item[key]));
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);
563
583
  }
564
584
 
565
585
  /**
@@ -685,19 +705,22 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
685
705
  }
686
706
 
687
707
  _arrayPropertiesTemplate() {
688
- const minCount = this._getValue(this._resolvedType, this.ns.w3.shacl.minCount)
689
- const maxCount = this._getValue(this._resolvedType, this.ns.w3.shacl.maxCount)
708
+ if (!this.noArrayInfo) {
709
+ const minCount = this._getValue(this._resolvedType, this.ns.w3.shacl.minCount)
710
+ const maxCount = this._getValue(this._resolvedType, this.ns.w3.shacl.maxCount)
690
711
 
691
- return html`
692
- ${minCount !== undefined ? this._arrayPropertyTemplate('Minimum array length:', minCount, 'Minimum amount of items in array') : ''}
693
- ${maxCount !== undefined ? this._arrayPropertyTemplate('Maximum array length:', maxCount, 'Maximum amount of items in array') : ''}
694
- `
712
+ return html`
713
+ ${minCount !== undefined ? this._arrayPropertyTemplate('Minimum array length:', minCount, 'Minimum amount of items in array') : ''}
714
+ ${maxCount !== undefined ? this._arrayPropertyTemplate('Maximum array length:', maxCount, 'Maximum amount of items in array') : ''}
715
+ `
716
+ }
717
+ return html``
695
718
  }
696
719
 
697
720
  /**
698
721
  * @return {TemplateResult} Templates for object properties
699
722
  */
700
- _arrayTemplate() {
723
+ _arrayTemplate() {
701
724
  const items = this._computeArrayProperties(this._resolvedType) || [];
702
725
  const documents = items.map(
703
726
  (item) => html`
@@ -737,9 +760,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
737
760
  <span>Array of:</span>
738
761
  <div class="array-children">
739
762
  ${documents}
740
- </div>`
763
+ </div>`
741
764
  : html`${documents}`
742
- }
765
+ }
743
766
 
744
767
  ${this._arrayPropertiesTemplate()}
745
768
  `;
@@ -753,7 +776,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
753
776
  const selected = this.selectedUnion;
754
777
  const selectTypeCallback = this._selectType.bind(this, 'selectedUnion');
755
778
  const key = this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf);
756
- const type = this._computeProperty(this._resolvedType, key,selected);
779
+ const type = this._computeProperty(this._resolvedType, key, selected);
757
780
  const typeName = 'union'
758
781
  const label = 'Any of'
759
782
  return this._multiTypeTemplate({ label, items, typeName, selected, selectTypeCallback, type });
@@ -850,10 +873,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
850
873
  }
851
874
  return html` ${items.map(
852
875
  (item) => html` ${item.label
853
- ? html`<p class="inheritance-label">
876
+ ? html`<p class="inheritance-label">
854
877
  Properties inherited from <b>${item.label}</b>.
855
878
  </p>`
856
- : html`<p class="inheritance-label">Properties defined inline.</p>`}
879
+ : html`<p class="inheritance-label">Properties defined inline.</p>`}
857
880
  <api-type-document
858
881
  class="and-document"
859
882
  .amf="${this.amf}"
@@ -882,12 +905,12 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
882
905
  return html`<style>${this.styles}</style>
883
906
  <section class="examples" ?hidden="${!this._renderMainExample}">
884
907
  ${this.shouldRenderMediaSelector
885
- ? html`<div class="media-type-selector">
908
+ ? html`<div class="media-type-selector">
886
909
  <span>Media type:</span>
887
910
  ${mediaTypes.map((item, index) => {
888
- const selected = this.selectedMediaType === index;
889
- const pressed = selected ? 'true' : 'false';
890
- return html`<anypoint-button
911
+ const selected = this.selectedMediaType === index;
912
+ const pressed = selected ? 'true' : 'false';
913
+ return html`<anypoint-button
891
914
  part="content-action-button"
892
915
  class="media-toggle"
893
916
  data-index="${index}"
@@ -898,9 +921,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) {
898
921
  title="Select ${item} media type"
899
922
  >${item}</anypoint-button
900
923
  >`;
901
- })}
924
+ })}
902
925
  </div>`
903
- : ''}
926
+ : ''}
904
927
 
905
928
  <api-resource-example-document
906
929
  .amf="${this.amf}"
@@ -582,6 +582,7 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) {
582
582
  ?compatibility="${this.compatibility}"
583
583
  ?noExamplesActions="${this.noExamplesActions}"
584
584
  noMainExample
585
+ noArrayInfo
585
586
  .mediaType="${this.mediaType}"
586
587
  ?graph="${this.graph}"
587
588
  ></api-type-document>`;