From 7c06c59dabfec1b7bd9110aa256fe637384d1a52 Mon Sep 17 00:00:00 2001 From: Carolina Wright Date: Wed, 5 Jul 2023 09:42:17 -0300 Subject: [PATCH 1/3] fix: showing required item when it shouldnt --- src/PropertyShapeDocument.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/PropertyShapeDocument.js b/src/PropertyShapeDocument.js index 7f8d8d2..32f3135 100644 --- a/src/PropertyShapeDocument.js +++ b/src/PropertyShapeDocument.js @@ -390,6 +390,13 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) { return !!parentTypeName; } + _toBoolean(value) { + if (typeof value === 'boolean') { + return value + } + return value === 'true' + } + /** * Computes value for `isRequired` property. * In AMF model a property is required when `http://www.w3.org/ns/shacl#minCount` @@ -404,10 +411,11 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) { } shape = this._resolve(shape); if (this._hasType(shape, this.ns.aml.vocabularies.apiContract.Parameter)) { - return /** @type boolean */ Boolean(this._getValue( + const required = Boolean(this._getValue( shape, this.ns.aml.vocabularies.apiContract.required - )); + )) + return this._toBoolean(required); } const data = this._getValue(shape, this.ns.w3.shacl.minCount); return data !== undefined && Number(data) !== 0; From f365ecc4b9e97f198be12f62f86ec5aad18fd345 Mon Sep 17 00:00:00 2001 From: Carolina Wright Date: Wed, 5 Jul 2023 09:42:21 -0300 Subject: [PATCH 2/3] 4.2.27 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 728f6e0..723fb14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@api-components/api-type-document", - "version": "4.2.26", + "version": "4.2.27", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index cc8bc87..7330b2c 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.26", + "version": "4.2.27", "license": "Apache-2.0", "main": "index.js", "module": "index.js", From 55060832ca8aa729006768f5ae3c502a7264741a Mon Sep 17 00:00:00 2001 From: Carolina Wright Date: Wed, 5 Jul 2023 09:43:44 -0300 Subject: [PATCH 3/3] fix: showing required item when it shouldnt --- src/PropertyShapeDocument.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PropertyShapeDocument.js b/src/PropertyShapeDocument.js index 32f3135..7ce043e 100644 --- a/src/PropertyShapeDocument.js +++ b/src/PropertyShapeDocument.js @@ -411,10 +411,10 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) { } shape = this._resolve(shape); if (this._hasType(shape, this.ns.aml.vocabularies.apiContract.Parameter)) { - const required = Boolean(this._getValue( + const required = this._getValue( shape, this.ns.aml.vocabularies.apiContract.required - )) + ) return this._toBoolean(required); } const data = this._getValue(shape, this.ns.w3.shacl.minCount);