From 7f7c34efc05a9bb890de7963debe5fea65232d47 Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 17:43:32 -0300 Subject: [PATCH 1/8] chore: add map for additionalProperties in _computeProperties method in ApiTypeDocument.js --- src/ApiTypeDocument.js | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/ApiTypeDocument.js b/src/ApiTypeDocument.js index 3c02d05..c0c6276 100644 --- a/src/ApiTypeDocument.js +++ b/src/ApiTypeDocument.js @@ -560,8 +560,15 @@ 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 properties = this._ensureArray(item[propertyKey]) + const additionalPropertieKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema); + if (!item[additionalPropertieKey]) { + return properties + } + const additionalProperties = this._ensureArray(item[additionalPropertieKey][0][propertyKey]) + const result = [...properties, ...additionalProperties] + return result } /** @@ -702,7 +709,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 +749,9 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { Array of:
${documents} -
` + ` : html`${documents}` - } + } ${this._arrayPropertiesTemplate()} `; @@ -758,7 +765,7 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { const selected = this.selectedUnion; const selectTypeCallback = this._selectType.bind(this, 'selectedUnion'); const key = this._getAmfKey(this.ns.aml.vocabularies.shapes.anyOf); - const type = this._computeProperty(this._resolvedType, key,selected); + const type = this._computeProperty(this._resolvedType, key, selected); const typeName = 'union' const label = 'Any of' return this._multiTypeTemplate({ label, items, typeName, selected, selectTypeCallback, type }); @@ -855,10 +862,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { } return html` ${items.map( (item) => html` ${item.label - ? html`

+ ? html`

Properties inherited from ${item.label}.

` - : html`

Properties defined inline.

`} + : html`

Properties defined inline.

`} ${this.styles}
${this.shouldRenderMediaSelector - ? html`
+ ? html`
Media type: ${mediaTypes.map((item, index) => { - const selected = this.selectedMediaType === index; - const pressed = selected ? 'true' : 'false'; - return html`${item}`; - })} + })}
` - : ''} + : ''} Date: Wed, 31 Jan 2024 17:43:44 -0300 Subject: [PATCH 2/8] 4.2.29 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 65bbdee..ffcd853 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "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", diff --git a/package.json b/package.json index 5c3195a..1236826 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", From fd360890e6cce127c7d2efc3f529e254f5ca2ab2 Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 18:09:02 -0300 Subject: [PATCH 3/8] chore: update @api-components/amf-helper-mixin version to 4.5.24 --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ffcd853..1999226 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,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", @@ -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" } diff --git a/package.json b/package.json index 1236826..88c7c58 100644 --- a/package.json +++ b/package.json @@ -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", From 88eecbdff31456d3b9a6cb1e24dfc5aeaac59c67 Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 19:11:41 -0300 Subject: [PATCH 4/8] chore: refactor _getProperties method in ApiTypeDocument.js --- src/ApiTypeDocument.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/ApiTypeDocument.js b/src/ApiTypeDocument.js index c0c6276..62fd917 100644 --- a/src/ApiTypeDocument.js +++ b/src/ApiTypeDocument.js @@ -560,15 +560,24 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { if (Array.isArray(item)) { return item; } + const propertyKey = this._getAmfKey(this.ns.w3.shacl.property); - const properties = this._ensureArray(item[propertyKey]) - const additionalPropertieKey = this._getAmfKey(this.ns.w3.shacl.additionalPropertiesSchema); - if (!item[additionalPropertieKey]) { - return properties - } - const additionalProperties = this._ensureArray(item[additionalPropertieKey][0][propertyKey]) - const result = [...properties, ...additionalProperties] - return result + 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) + } + + // If the item does have additional properties, ensure they are in an array + const additionalProperties = this._ensureArray(item[additionalPropertiesKey][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); } /** From 147f5bd6c38dfa9d885fe8864f85d47e6184892c Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 19:13:49 -0300 Subject: [PATCH 5/8] 4.2.30 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1999226..7162797 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api-components/api-type-document", - "version": "4.2.29", + "version": "4.2.30", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/api-type-document", - "version": "4.2.29", + "version": "4.2.30", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/arc-marked": "^1.1.0", diff --git a/package.json b/package.json index 88c7c58..6d7ca15 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.29", + "version": "4.2.30", "license": "Apache-2.0", "main": "index.js", "module": "index.js", From b26f8e99d5bff98c3bd6c082e9b35472263749b6 Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 19:20:51 -0300 Subject: [PATCH 6/8] Update package.json version to 4.2.29 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6d7ca15..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.30", + "version": "4.2.29", "license": "Apache-2.0", "main": "index.js", "module": "index.js", @@ -99,4 +99,4 @@ "eslint --fix" ] } -} +} \ No newline at end of file From c5b52f689d65c16851c569363e01900a596f202b Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 19:50:11 -0300 Subject: [PATCH 7/8] chore: refactor additional properties handling in ApiTypeDocument.js --- src/ApiTypeDocument.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ApiTypeDocument.js b/src/ApiTypeDocument.js index 62fd917..db3894f 100644 --- a/src/ApiTypeDocument.js +++ b/src/ApiTypeDocument.js @@ -570,8 +570,10 @@ export class ApiTypeDocument extends PropertyDocumentMixin(LitElement) { 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(item[additionalPropertiesKey][0][propertyKey]) + const additionalProperties = this._ensureArray(additionalPropertiesSchema[0][propertyKey]) // Combine the item's properties and additional properties const combinedProperties = [...itemProperties, ...additionalProperties] From 5b5055dd7313eafcf16a5d00c42bf36f52148e7c Mon Sep 17 00:00:00 2001 From: alexperez Date: Wed, 31 Jan 2024 19:52:35 -0300 Subject: [PATCH 8/8] Update package-lock.json version --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7162797..e6d4a5c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api-components/api-type-document", - "version": "4.2.30", + "version": "4.2.29", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/api-type-document", - "version": "4.2.30", + "version": "4.2.29", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/arc-marked": "^1.1.0", @@ -27795,4 +27795,4 @@ "dev": true } } -} +} \ No newline at end of file