diff --git a/package-lock.json b/package-lock.json index 65bbdee..e6d4a5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { "name": "@api-components/api-type-document", - "version": "4.2.28", + "version": "4.2.29", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/api-type-document", - "version": "4.2.24", + "version": "4.2.29", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/arc-marked": "^1.1.0", "@advanced-rest-client/markdown-styles": "^3.1.4", "@anypoint-web-components/anypoint-button": "^1.2.3", - "@api-components/amf-helper-mixin": "^4.5.6", + "@api-components/amf-helper-mixin": "^4.5.24", "@api-components/api-annotation-document": "^4.1.0", "@api-components/api-resource-example-document": "^4.3.3", "@open-wc/dedupe-mixin": "^1.3.0", @@ -578,9 +578,9 @@ } }, "node_modules/@api-components/amf-helper-mixin": { - "version": "4.5.21", - "resolved": "https://registry.npmjs.org/@api-components/amf-helper-mixin/-/amf-helper-mixin-4.5.21.tgz", - "integrity": "sha512-h7q4lI0TMdG769Oxt+K/USaUTNK4SRBk4IyXehmPCxev6NnHskqBsc/us0fx9OjCpYvIN1WpyKa7V3aEGqxCUQ==", + "version": "4.5.24", + "resolved": "https://registry.npmjs.org/@api-components/amf-helper-mixin/-/amf-helper-mixin-4.5.24.tgz", + "integrity": "sha512-rxjh+9X4OC0pFbYsqXTmiGTr8JM2xkc/oIyGuW9Ez+CKFcF6tb/7xcog5ZC/9CUQHfa5bFrJ5qXH+wjRyMx3hA==", "dependencies": { "amf-json-ld-lib": "0.0.14" } @@ -16008,9 +16008,9 @@ } }, "@api-components/amf-helper-mixin": { - "version": "4.5.21", - "resolved": "https://registry.npmjs.org/@api-components/amf-helper-mixin/-/amf-helper-mixin-4.5.21.tgz", - "integrity": "sha512-h7q4lI0TMdG769Oxt+K/USaUTNK4SRBk4IyXehmPCxev6NnHskqBsc/us0fx9OjCpYvIN1WpyKa7V3aEGqxCUQ==", + "version": "4.5.24", + "resolved": "https://registry.npmjs.org/@api-components/amf-helper-mixin/-/amf-helper-mixin-4.5.24.tgz", + "integrity": "sha512-rxjh+9X4OC0pFbYsqXTmiGTr8JM2xkc/oIyGuW9Ez+CKFcF6tb/7xcog5ZC/9CUQHfa5bFrJ5qXH+wjRyMx3hA==", "requires": { "amf-json-ld-lib": "0.0.14" } @@ -27795,4 +27795,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 5c3195a..9fb9fe8 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@api-components/api-type-document", "description": "A documentation table for type (resource) properties. Works with AMF data model", - "version": "4.2.28", + "version": "4.2.29", "license": "Apache-2.0", "main": "index.js", "module": "index.js", @@ -28,7 +28,7 @@ "@advanced-rest-client/arc-marked": "^1.1.0", "@advanced-rest-client/markdown-styles": "^3.1.4", "@anypoint-web-components/anypoint-button": "^1.2.3", - "@api-components/amf-helper-mixin": "^4.5.6", + "@api-components/amf-helper-mixin": "^4.5.24", "@api-components/api-annotation-document": "^4.1.0", "@api-components/api-resource-example-document": "^4.3.3", "@open-wc/dedupe-mixin": "^1.3.0", @@ -99,4 +99,4 @@ "eslint --fix" ] } -} +} \ No newline at end of file diff --git a/src/ApiTypeDocument.js b/src/ApiTypeDocument.js index 3c02d05..db3894f 100644 --- a/src/ApiTypeDocument.js +++ b/src/ApiTypeDocument.js @@ -560,8 +560,26 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { if (Array.isArray(item)) { return item; } - const key = this._getAmfKey(this.ns.w3.shacl.property); - return this._filterReadOnlyProperties(this._ensureArray(item[key])); + + const propertyKey = this._getAmfKey(this.ns.w3.shacl.property); + const itemProperties = this._ensureArray(item[propertyKey]) + const additionalPropertiesKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema); + + // If the item doesn't have additional properties, filter the read-only properties and return + if (!item[additionalPropertiesKey]) { + return this._filterReadOnlyProperties(itemProperties) + } + + const additionalPropertiesSchema = this._ensureArray(item[additionalPropertiesKey]) + + // If the item does have additional properties, ensure they are in an array + const additionalProperties = this._ensureArray(additionalPropertiesSchema[0][propertyKey]) + + // Combine the item's properties and additional properties + const combinedProperties = [...itemProperties, ...additionalProperties] + + // Filter the read-only properties and return + return this._filterReadOnlyProperties(combinedProperties); } /** @@ -702,7 +720,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { /** * @return {TemplateResult} Templates for object properties */ - _arrayTemplate() { + _arrayTemplate() { const items = this._computeArrayProperties(this._resolvedType) || []; const documents = items.map( (item) => html` @@ -742,9 +760,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { Array of:
+ ? html`
Properties inherited from ${item.label}.
` - : html`Properties defined inline.
`} + : html`Properties defined inline.
`}