diff --git a/.gitignore b/.gitignore index 8a4b5f22b..a87a2540f 100644 --- a/.gitignore +++ b/.gitignore @@ -66,6 +66,7 @@ demo/models/flattened/*.json !demo/models/avro.json !demo/models/avro2.json !demo/models/grpc-test.json +!demo/models/grpc-test-compact.json .idea/ .sfdx diff --git a/demo/element/app.js b/demo/element/app.js index 945b09f3f..91d3eee29 100644 --- a/demo/element/app.js +++ b/demo/element/app.js @@ -14,6 +14,7 @@ class ApicApplication extends DemoBase { constructor() { super(); this.apis = [ + ['grpc-test', 'gRPC API'], ['google-drive-api', 'Google Drive API'], ['httpbin', 'HTTPbin API'], ['data-type-fragment', 'RAML data type fragment'], diff --git a/demo/models/grpc-test-compact.json b/demo/models/grpc-test-compact.json new file mode 100644 index 000000000..0c5168e66 --- /dev/null +++ b/demo/models/grpc-test-compact.json @@ -0,0 +1,1045 @@ +[ + { + "@id": "", + "doc:declares": [ + { + "@id": "#1", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#2", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#3", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "query", + "__apicResolved": true + } + ], + "__apicResolved": true + }, + { + "@id": "#4", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#5", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer", + "__apicResolved": true + } + ], + "raml-shapes:format": [ + { + "@value": "int32", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 2, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "page_number", + "__apicResolved": true + } + ], + "__apicResolved": true + }, + { + "@id": "#6", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#7", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer", + "__apicResolved": true + } + ], + "raml-shapes:format": [ + { + "@value": "int32", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 3, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "results_per_page", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.SearchRequest", + "__apicResolved": true + } + ], + "core:name": [ + { + "@value": "SearchRequest", + "__apicResolved": true + } + ], + "__apicResolved": true + }, + { + "@id": "#9", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#10", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#11", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#12", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#13", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#14", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1 + } + ], + "sh:name": [ + { + "@value": "url" + } + ] + }, + { + "@id": "#15", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#16", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 2 + } + ], + "sh:name": [ + { + "@value": "title" + } + ] + }, + { + "@id": "#17", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#18", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#19", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 3 + } + ], + "sh:name": [ + { + "@value": "snippets" + } + ] + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.Result" + } + ], + "core:name": [ + { + "@value": "Result" + } + ] + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1 + } + ], + "sh:name": [ + { + "@value": "results" + } + ] + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.SearchResponse" + } + ], + "core:name": [ + { + "@value": "SearchResponse" + } + ] + }, + { + "@id": "#12", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#13", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#14", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1 + } + ], + "sh:name": [ + { + "@value": "url" + } + ] + }, + { + "@id": "#15", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#16", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 2 + } + ], + "sh:name": [ + { + "@value": "title" + } + ] + }, + { + "@id": "#17", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#18", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#19", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 3 + } + ], + "sh:name": [ + { + "@value": "snippets" + } + ] + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.Result" + } + ], + "core:name": [ + { + "@value": "Result" + } + ] + } + ], + "@type": [ + "doc:Document", + "doc:Fragment", + "doc:Module", + "doc:Unit" + ], + "doc:encodes": [ + { + "@id": "#22", + "@type": [ + "apiContract:WebAPI", + "apiContract:API", + "doc:RootDomainElement", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "test_grpc_FF" + } + ], + "apiContract:endpoint": [ + { + "@id": "#23", + "@type": [ + "apiContract:EndPoint", + "doc:DomainElement" + ], + "core:name": [ + { + "@value": "SearchService" + } + ], + "apiContract:supportedOperation": [ + { + "@id": "#24", + "@type": [ + "apiContract:Operation", + "core:Operation", + "doc:DomainElement" + ], + "apiContract:method": [ + { + "@value": "post" + } + ], + "core:name": [ + { + "@value": "Search" + } + ], + "apiContract:expects": [ + { + "@id": "#25", + "@type": [ + "apiContract:Request", + "core:Request", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:payload": [ + { + "@id": "#26", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "core:mediaType": [ + { + "@value": "application/grpc" + } + ], + "raml-shapes:schema": [ + { + "@id": "#1", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#2", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#3", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "query", + "__apicResolved": true + } + ], + "__apicResolved": true + }, + { + "@id": "#4", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#5", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer", + "__apicResolved": true + } + ], + "raml-shapes:format": [ + { + "@value": "int32", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 2, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "page_number", + "__apicResolved": true + } + ], + "__apicResolved": true + }, + { + "@id": "#6", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#7", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#integer", + "__apicResolved": true + } + ], + "raml-shapes:format": [ + { + "@value": "int32", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 3, + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": "results_per_page", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.SearchRequest", + "__apicResolved": true + } + ], + "core:name": [ + { + "@value": "SearchRequest", + "__apicResolved": true + } + ], + "__apicResolved": true + } + ] + } + ] + } + ], + "apiContract:returns": [ + { + "@id": "#27", + "@type": [ + "apiContract:Response", + "core:Response", + "apiContract:Message", + "doc:DomainElement" + ], + "apiContract:payload": [ + { + "@id": "#28", + "@type": [ + "apiContract:Payload", + "core:Payload", + "doc:DomainElement" + ], + "core:mediaType": [ + { + "@value": "application/protobuf" + } + ], + "raml-shapes:schema": [ + { + "@id": "#9", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#10", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#11", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#12", + "@type": [ + "sh:NodeShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:property": [ + { + "@id": "#13", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#14", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1 + } + ], + "sh:name": [ + { + "@value": "url" + } + ] + }, + { + "@id": "#15", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#16", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 2 + } + ], + "sh:name": [ + { + "@value": "title" + } + ] + }, + { + "@id": "#17", + "@type": [ + "sh:PropertyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:range": [ + { + "@id": "#18", + "@type": [ + "raml-shapes:ArrayShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "raml-shapes:items": [ + { + "@id": "#19", + "@type": [ + "raml-shapes:ScalarShape", + "raml-shapes:AnyShape", + "sh:Shape", + "raml-shapes:Shape", + "doc:DomainElement" + ], + "sh:datatype": [ + { + "@id": "http://www.w3.org/2001/XMLSchema#string" + } + ] + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 3 + } + ], + "sh:name": [ + { + "@value": "snippets" + } + ] + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.Result" + } + ], + "core:name": [ + { + "@value": "Result" + } + ] + } + ] + } + ], + "raml-shapes:serializationOrder": [ + { + "@value": 1 + } + ], + "sh:name": [ + { + "@value": "results" + } + ] + } + ], + "sh:name": [ + { + "@value": ".test_grpc_FF.SearchResponse" + } + ], + "core:name": [ + { + "@value": "SearchResponse" + } + ] + } + ] + } + ] + } + ], + "apiContract:operationId": [ + { + "@value": "Search" + } + ] + } + ] + } + ] + } + ], + "doc:root": [ + { + "@value": true + } + ], + "doc:package": [ + { + "@value": "test_grpc_FF" + } + ], + "doc:processingData": [ + { + "@id": "#29", + "@type": [ + "doc:APIContractProcessingData" + ], + "apiContract:modelVersion": [ + { + "@value": "3.11.0" + } + ], + "doc:transformed": [ + { + "@value": true + } + ], + "doc:sourceSpec": [ + { + "@value": "Grpc" + } + ] + } + ], + "sourcemaps:sources": [ + { + "@id": "#/source-map", + "@type": [ + "sourcemaps:SourceMap" + ], + "sourcemaps:grpc-raw-proto": [ + { + "@id": "#/source-map/grpc-raw-proto/element_0", + "sourcemaps:element": [ + { + "@value": "amf://id" + } + ], + "sourcemaps:value": [ + { + "@value": "\nsyntax = \"proto3\";\n\npackage test_grpc_FF;\n\nmessage SearchRequest {\n string query = 1;\n int32 page_number = 2;\n int32 results_per_page = 3;\n}\n\nmessage SearchResponse {\n repeated Result results = 1;\n}\n\nmessage Result {\n string url = 1;\n string title = 2;\n repeated string snippets = 3;\n}\n\nservice SearchService {\n rpc Search(SearchRequest) returns (SearchResponse);\n}" + } + ] + } + ] + } + ], + "@context": { + "@base": "amf://id", + "raml-shapes": "http://a.ml/vocabularies/shapes#", + "doc": "http://a.ml/vocabularies/document#", + "apiContract": "http://a.ml/vocabularies/apiContract#", + "core": "http://a.ml/vocabularies/core#", + "sourcemaps": "http://a.ml/vocabularies/document-source-maps#", + "sh": "http://www.w3.org/ns/shacl#" + } + } +] \ No newline at end of file diff --git a/demo/standalone/app.js b/demo/standalone/app.js index d63f921b9..03d4b149c 100644 --- a/demo/standalone/app.js +++ b/demo/standalone/app.js @@ -11,6 +11,7 @@ class ApicApplication extends DemoBase { constructor() { super(); this.apis = [ + ['grpc-test', 'gRPC API'], ['google-drive-api', 'Google Drive API'], ['httpbin', 'HTTPbin API'], ['oAuth2', 'oAuth2'], diff --git a/demo/themed/anypoint.js b/demo/themed/anypoint.js index 21174114d..e80d22231 100644 --- a/demo/themed/anypoint.js +++ b/demo/themed/anypoint.js @@ -14,12 +14,13 @@ class ApicApplication extends DemoBase { super(); this.apis = [ ['grpc-test', 'gRPC API'], + ['agents-api', 'Agents API'], + ['agents-api-compact', 'Agents API Compact'], ['google-drive-api', 'Google Drive API'], ['httpbin', 'HTTPbin API'], ['data-type-fragment', 'RAML data type fragment'], ['demo-api', 'Demo API'], ['APIC-538', 'APIC-538'], - ['agents-api', 'Agents API Compact'], ]; } diff --git a/package-lock.json b/package-lock.json index 2f478e72e..2f3859319 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "api-console", - "version": "6.6.57", + "version": "6.6.58", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "api-console", - "version": "6.6.57", + "version": "6.6.58", "license": "CPAL-1.0", "dependencies": { "@advanced-rest-client/arc-icons": "^3.2.2", @@ -15,7 +15,7 @@ "@anypoint-web-components/anypoint-button": "^1.1.1", "@api-components/amf-helper-mixin": "^4.5.36", "@api-components/api-console-ext-comm": "^3.0.0", - "@api-components/api-documentation": "^6.1.7", + "@api-components/api-documentation": "^6.1.8", "@api-components/api-navigation": "^4.3.20", "@api-components/api-request": "^0.3.8", "@api-components/api-summary": "^4.6.16", @@ -1042,9 +1042,9 @@ } }, "node_modules/@api-components/api-documentation": { - "version": "6.1.7", - "resolved": "https://registry.npmjs.org/@api-components/api-documentation/-/api-documentation-6.1.7.tgz", - "integrity": "sha512-YXEY8HwCpbq3oFxIte5r/JiLKC3cbn43DI4kCq9zXz2XSL4t+5HuhxaJae7cZY+tsw1QOnCJ3jFu7oG3ClofqQ==", + "version": "6.1.8", + "resolved": "https://registry.npmjs.org/@api-components/api-documentation/-/api-documentation-6.1.8.tgz", + "integrity": "sha512-nrRI7lzKVojjTlWgaQTC+W90WBtD+vgr9IVYUa2jPYvIfDd0WKlWOZ5km7FsZsknFa2h8ystUYCSe5FeyKTlvQ==", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/events-target-mixin": "^3.2.4", diff --git a/package.json b/package.json index 8138fe774..942cf82ad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "api-console", "description": "The API Console to automatically generate API documentation from RAML and OAS files.", - "version": "6.6.57", + "version": "6.6.58", "license": "CPAL-1.0", "main": "index.js", "module": "index.js", @@ -39,7 +39,7 @@ "@anypoint-web-components/anypoint-button": "^1.1.1", "@api-components/amf-helper-mixin": "^4.5.36", "@api-components/api-console-ext-comm": "^3.0.0", - "@api-components/api-documentation": "^6.1.7", + "@api-components/api-documentation": "^6.1.8", "@api-components/api-navigation": "^4.3.20", "@api-components/api-request": "^0.3.8", "@api-components/api-summary": "^4.6.16", diff --git a/src/ApiConsole.js b/src/ApiConsole.js index 9a7141b75..d57d22d58 100644 --- a/src/ApiConsole.js +++ b/src/ApiConsole.js @@ -463,7 +463,8 @@ export class ApiConsole extends AmfHelperMixin(LitElement) { const webApi = this._computeApi(amf); this.webApi = webApi; this.methodName = this._computeMethodName(this.selectedShape, webApi); - if (!this._isWebAPI(amf)) { + // Hide try-it panel for gRPC APIs or non-WebAPI models + if (!this._isWebAPI(amf) || this._isGrpcApi(amf)) { this._noTryItValue = true; } } diff --git a/src/ApiConsoleApp.js b/src/ApiConsoleApp.js index 4a92c5a37..9745c1f90 100644 --- a/src/ApiConsoleApp.js +++ b/src/ApiConsoleApp.js @@ -268,6 +268,8 @@ export class ApiConsoleApp extends ApiConsole { */ async _processModelChange() { super._processModelChange(); + // Update try-it panel visibility based on API type (gRPC detection) + this._updateRenderInlineTyit(); this.apiTitle = this._computeApiTitle(this.webApi); await this.updateComplete; if (window.history.state) { diff --git a/test/api-console.amf.test.js b/test/api-console.amf.test.js index a83592bb7..6e650bfef 100644 --- a/test/api-console.amf.test.js +++ b/test/api-console.amf.test.js @@ -36,6 +36,7 @@ export const selectOperation = (element, endpointName, operationName) => { describe('ApiConsole', () => { const asyncApi = 'async-api'; + const grpcApi = 'grpc-test'; const multiServer = 'multi-server'; const apic553 = 'APIC-553'; const apic554 = 'APIC-554'; @@ -212,6 +213,55 @@ describe('ApiConsole', () => { }); }); + describe('gRPC API', () => { + [ + new ApiDescribe('Regular model'), + new ApiDescribe('Compact model', true), + ].forEach(({ label, compact }) => { + describe(label, () => { + let amf; + let element; + + before(async () => { + amf = await AmfLoader.load({ compact, fileName: grpcApi, flattened: false }); + }); + + beforeEach(async () => { + element = await amfFixture(amf); + await aTimeout(0); + }); + + it('should have _noTryItValue set to true for gRPC API', () => { + assert.isTrue(element._noTryItValue, '_noTryItValue should be true for gRPC API'); + }); + + it('should detect gRPC API correctly', () => { + const isGrpc = element._isGrpcApi(amf); + assert.isTrue(isGrpc, 'Should detect gRPC API'); + }); + + it('should hide try-it button when selecting a method', async () => { + const webApi = AmfLoader.lookupWebApi(amf); + const endpoints = element._computeEndpoints(webApi); + if (endpoints && endpoints.length > 0) { + const operations = element._computePropertyArray( + endpoints[0], + element.ns.aml.vocabularies.apiContract.supportedOperation + ); + if (operations && operations.length > 0) { + element.selectedShape = operations[0]['@id']; + element.selectedShapeType = 'method'; + await nextFrame(); + await nextFrame(); + + assert.isTrue(element._noTryItValue, 'Try-it button should be hidden for gRPC API method'); + } + } + }); + }); + }); + }); + describe('APIC-553', () => { [ new ApiDescribe('Regular model'),