From 515cccdf077b21652ddbbb893a821745a591bcac Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Thu, 2 May 2024 15:53:19 -0300 Subject: [PATCH 1/3] feat(W-15607551): show servers name --- src/ApiMethodDocumentation.js | 24 +++++++++++++++++++++ src/ApiUrl.js | 40 +++++++++++++++++++++++------------ test/api-url.test.js | 4 ++-- 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/ApiMethodDocumentation.js b/src/ApiMethodDocumentation.js index 0e64416..6a44325 100644 --- a/src/ApiMethodDocumentation.js +++ b/src/ApiMethodDocumentation.js @@ -232,6 +232,14 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) { * This is a map of the type name to the binding name. */ bindings: {type: Array}, + /** + * Adds a servers to async API + * + * @param {string} url - The URL of the server. + * @param {object} [description] - An object containing a string `description` property. + */ + servers: {type:Array}, + _servers: {type:Array}, }; } @@ -335,6 +343,21 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) { this._processServerInfo(); } + get servers() { + return this._servers; + } + + set servers(value) { + + const old = this._servers; + /* istanbul ignore if */ + if (old === value) { + return; + } + this._servers = value; + this.requestUpdate('servers', old); + } + get _titleHidden() { if (!this.noTryIt) { return false; @@ -897,6 +920,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) { (this._getValue(item, this.ns.aml.vocabularies.core.name))); + if(servers){ + return servers.map((item)=>(this._getValue(item, this.ns.aml.vocabularies.core.name))); } // try to find root server (only one) that is received by property @@ -278,11 +294,9 @@ export class ApiUrl extends AmfHelperMixin(LitElement) { } renderAsyncApi(asyncServersNames){ - const { url, _endpoint } = this; - if(!_endpoint){ - return '' - } - return html` + const { url } = this; + + return html`
${this._getMethodTemplate()} diff --git a/test/api-url.test.js b/test/api-url.test.js index d8a48e6..96178e3 100644 --- a/test/api-url.test.js +++ b/test/api-url.test.js @@ -166,8 +166,8 @@ describe('', () => { await nextFrame(); await nextFrame(); - const url = 'mqtt://api.streetlights.smartylighting.com:{port}' - assert.equal(element.shadowRoot.querySelector('.url-value').textContent.trim(), url); + const expectedServer = 'production' + assert.equal(element.shadowRoot.querySelector('.url-value').textContent.trim(), expectedServer); }); }); }); From a325aa338fc5e898d7a5f9d9926e70516b59005b Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Thu, 2 May 2024 15:53:33 -0300 Subject: [PATCH 2/3] 5.2.22 --- 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 110a07a..242e90c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@api-components/api-method-documentation", - "version": "5.2.21", + "version": "5.2.22", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@api-components/api-method-documentation", - "version": "5.2.21", + "version": "5.2.22", "license": "Apache-2.0", "dependencies": { "@advanced-rest-client/arc-icons": "^3.3.4", diff --git a/package.json b/package.json index ae78def..8f95c29 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@api-components/api-method-documentation", "description": "A HTTP method documentation build from AMF model", - "version": "5.2.21", + "version": "5.2.22", "license": "Apache-2.0", "main": "index.js", "module": "index.js", From 36734a4600bf99ee663404eb5bc50b8b61e9df90 Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Fri, 3 May 2024 11:59:16 -0300 Subject: [PATCH 3/3] feat(W-15607551): show servers name --- src/ApiMethodDocumentation.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ApiMethodDocumentation.js b/src/ApiMethodDocumentation.js index 6a44325..519eaf3 100644 --- a/src/ApiMethodDocumentation.js +++ b/src/ApiMethodDocumentation.js @@ -1249,6 +1249,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) { amf, compatibility, graph, + servers } = this; return html`
@@ -1257,6 +1258,7 @@ export class ApiMethodDocumentation extends AmfHelperMixin(LitElement) { .amf="${amf}" .method="${method}" .endpoint="${endpoint}" + .servers="${servers}" ?compatibility="${compatibility}" ?graph="${graph}" noTryit