From 72cf2067749a97034af0d59e6782f5bc4c937ace Mon Sep 17 00:00:00 2001 From: Alex Perez Date: Mon, 2 Mar 2026 05:11:08 -0300 Subject: [PATCH 1/4] fix(api-type-document): show gRPC message type names in oneOf composition Use document link-label when core name and shacl name are missing so gRPC oneOf message types display (e.g. HelloRequest) instead of 'Unnamed type'. Refs: W-21315032 Made-with: Cursor --- src/PropertyDocumentMixin.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PropertyDocumentMixin.js b/src/PropertyDocumentMixin.js index 5decc06..050bedd 100644 --- a/src/PropertyDocumentMixin.js +++ b/src/PropertyDocumentMixin.js @@ -524,6 +524,13 @@ const mxFunction = (base) => { if (!label) { label = this._getValue(item, this.ns.w3.shacl.name); } + // Check for link-label (gRPC message types) + if (!label) { + const linkLabelKey = this._getAmfKey( + this.ns.aml.vocabularies.document.linkLabel + ); + label = this._getValue(item, linkLabelKey); + } if ( !label && this._hasType(item, this.ns.aml.vocabularies.shapes.ScalarShape) From 826c6053c598018a9cde962ccd773db6417b6325 Mon Sep 17 00:00:00 2001 From: Alex Perez Date: Mon, 2 Mar 2026 05:17:19 -0300 Subject: [PATCH 2/4] fix(api-type-document): get oneOf label from NodeShape property range (gRPC) When anyOf/oneOf member is an anonymous NodeShape wrapping a single property (e.g. gRPC message reference), take the type label from that property's range (core:name, shacl:name, or link-label). Refs: W-21315032 Made-with: Cursor --- src/PropertyDocumentMixin.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/PropertyDocumentMixin.js b/src/PropertyDocumentMixin.js index 050bedd..14ea0aa 100644 --- a/src/PropertyDocumentMixin.js +++ b/src/PropertyDocumentMixin.js @@ -531,6 +531,35 @@ const mxFunction = (base) => { ); label = this._getValue(item, linkLabelKey); } + // gRPC oneOf: label may be on the range of the single property (NodeShape wrapper) + if ( + !label && + this._hasType(item, this.ns.w3.shacl.NodeShape) + ) { + const propKey = this._getAmfKey(this.ns.w3.shacl.property); + const props = this._ensureArray(item[propKey]); + const firstProp = props && props[0]; + if (firstProp) { + const rangeKey = this._getAmfKey( + this.ns.aml.vocabularies.shapes.range + ); + const rangeArr = this._ensureArray(firstProp[rangeKey]); + const range = rangeArr && rangeArr[0]; + const resolvedRange = range ? this._resolve(range) : undefined; + if (resolvedRange) { + label = this._getValue(resolvedRange, this.ns.aml.vocabularies.core.name); + if (!label) { + label = this._getValue(resolvedRange, this.ns.w3.shacl.name); + } + if (!label) { + const linkLabelKey = this._getAmfKey( + this.ns.aml.vocabularies.document.linkLabel + ); + label = this._getValue(resolvedRange, linkLabelKey); + } + } + } + } if ( !label && this._hasType(item, this.ns.aml.vocabularies.shapes.ScalarShape) From ce6176338c90e05f4b89cfcf8ad709e4b6fff926 Mon Sep 17 00:00:00 2001 From: Alex Perez Date: Mon, 2 Mar 2026 09:06:51 -0300 Subject: [PATCH 3/4] fix(api-type-document): enhance type detection for Enum in PropertyDocumentMixin - Added logic to identify 'Enum' types in the mxFunction, improving type classification for shapes with allowed values. - Updated the API list template in index.js to include 'grpc-test' entry for better demo representation. - Adjusted rendering conditions in PropertyShapeDocument to ensure proper display of enum types. Refs: W-21315032 --- demo/index.js | 2 +- src/PropertyDocumentMixin.js | 18 +++++++++++++++++- src/PropertyShapeDocument.js | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/demo/index.js b/demo/index.js index 6944343..ca7bed5 100644 --- a/demo/index.js +++ b/demo/index.js @@ -99,11 +99,11 @@ class ApiDemo extends ApiDemoPage { _apiListTemplate() { return [ + ['grpc-test', 'GRPC test'], ['product-order-minimal', 'Product Order Minimal'], ['nested-examples-oas3', 'Nested Examples'], ['nullable-test', 'Nullable Test (Comprehensive)'], ['nulleable', 'Nulleable test'], - ['grpc-test', 'GRPC test'], ['shopper-products', 'shopper-products'], ['demo-api', 'Demo API'], ['avro', 'avro'], diff --git a/src/PropertyDocumentMixin.js b/src/PropertyDocumentMixin.js index 14ea0aa..925c54c 100644 --- a/src/PropertyDocumentMixin.js +++ b/src/PropertyDocumentMixin.js @@ -213,6 +213,11 @@ const mxFunction = (base) => { if (this._hasType(range, rs.RecursiveShape)) { return 'Recursive'; } + // Enum: ScalarShape or other shape with shacl:in (allowed values) + const inKey = this._getAmfKey(this.ns.w3.shacl.in); + if (range[inKey]) { + return 'Enum'; + } return 'Unknown type'; } @@ -272,8 +277,13 @@ const mxFunction = (base) => { return 'Bytes' case sc.fixed: return 'Fixed' - default: + default: { + const inKey = this._getAmfKey(this.ns.w3.shacl.in); + if (range[inKey]) { + return 'Enum'; + } return 'Unknown type'; + } } } @@ -557,6 +567,12 @@ const mxFunction = (base) => { ); label = this._getValue(resolvedRange, linkLabelKey); } + if ( + !label && + this._hasType(resolvedRange, this.ns.aml.vocabularies.shapes.ScalarShape) + ) { + label = this._computeRangeDataType(resolvedRange); + } } } } diff --git a/src/PropertyShapeDocument.js b/src/PropertyShapeDocument.js index 8b7f0e6..7a85dff 100644 --- a/src/PropertyShapeDocument.js +++ b/src/PropertyShapeDocument.js @@ -1028,7 +1028,8 @@ export class PropertyShapeDocument extends PropertyDocumentMixin(LitElement) { >Required` : ''} - ${this.isEnum + ${this.isEnum && + this._getTypeLabelData().dataType !== 'Enum' ? html` Date: Mon, 2 Mar 2026 10:50:13 -0300 Subject: [PATCH 4/4] 4.2.41 --- 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 dcdb2c7..b104183 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api-components/api-type-document", - "version": "4.2.40", + "version": "4.2.41", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/api-type-document", - "version": "4.2.40", + "version": "4.2.41", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/arc-marked": "^1.1.0", diff --git a/package.json b/package.json index 0f7f894..524ab9c 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.40", + "version": "4.2.41", "license": "Apache-2.0", "main": "index.js", "module": "index.js",