From d4b74aba1c5ea56b925c68db7fcbf7147753c987 Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Mon, 22 Apr 2024 15:56:45 -0300 Subject: [PATCH 1/3] feat(W-15520261): show header example when is asyncApi --- demo/index.js | 9 ++++++++- src/ApiHeadersDocument.js | 11 +++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/demo/index.js b/demo/index.js index d59d97a..1d212cd 100644 --- a/demo/index.js +++ b/demo/index.js @@ -29,7 +29,13 @@ class ApiDemo extends ApiDemoPage { const webApi = this._computeApi(this.amf); const method = this._computeMethodModel(webApi, id); const expects = this._computeExpects(method); - const headers = this._computeHeaders(expects); + let headers + if(expects){ + headers = this._computeHeaders(expects); + }else{ + const returns = this._computeReturns(method); + headers = this._computeHeaderSchema(returns[0]); + } this.headers = headers; this.hasData = true; } @@ -38,6 +44,7 @@ class ApiDemo extends ApiDemoPage { return [ ['demo-api', 'Demo API'], ['async-api', 'Async API'], + ['jldAsync26', 'Async API 26'], ].map(([file, label]) => html` ${label} - compact model ${label} diff --git a/src/ApiHeadersDocument.js b/src/ApiHeadersDocument.js index 7e23b3a..5264635 100644 --- a/src/ApiHeadersDocument.js +++ b/src/ApiHeadersDocument.js @@ -80,8 +80,10 @@ export class ApiHeadersDocument extends LitElement { } render() { - const { opened, headers, amf, narrow, compatibility, headerLevel, graph } = this; + const { opened, headers, amf, narrow, compatibility, headerLevel, graph, noMainExample } = this; const hasHeaders = !!(headers) && (!!headers.length || !!Object.keys(headers).length); + const noShowMainExample = noMainExample + return html`
` : html`

Headers are not required by this endpoint

`} @@ -153,6 +155,10 @@ export class ApiHeadersDocument extends LitElement { * Passed to `api-type-document`. Enables internal links rendering for types. */ graph: { type: Boolean }, + /** + * Use to define is show or hide mainExample + */ + noMainExample: { type: Boolean }, }; } @@ -167,6 +173,7 @@ export class ApiHeadersDocument extends LitElement { this.narrow = false; this.compatibility = false; this.graph = false; + this.noMainExample = true; } // Computes a label for the section toggle buttons. From 3a2ba5c1684ae4502f3b5b72689aa28987973a02 Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Mon, 22 Apr 2024 16:10:57 -0300 Subject: [PATCH 2/3] feat(W-15520261): show example when is asyncApi --- src/ApiHeadersDocument.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ApiHeadersDocument.js b/src/ApiHeadersDocument.js index 5264635..452a89f 100644 --- a/src/ApiHeadersDocument.js +++ b/src/ApiHeadersDocument.js @@ -82,7 +82,6 @@ export class ApiHeadersDocument extends LitElement { render() { const { opened, headers, amf, narrow, compatibility, headerLevel, graph, noMainExample } = this; const hasHeaders = !!(headers) && (!!headers.length || !!Object.keys(headers).length); - const noShowMainExample = noMainExample return html`
@@ -109,7 +108,7 @@ export class ApiHeadersDocument extends LitElement { ?narrow="${narrow}" ?graph="${graph}" noExamplesActions - ?noMainExample="${noShowMainExample}" + ?noMainExample="${noMainExample}" >` : html`

Headers are not required by this endpoint

`} From f47b0181429f8b1aefea8f37a34401b3dd642771 Mon Sep 17 00:00:00 2001 From: leandrogilcarrano Date: Mon, 22 Apr 2024 16:10:59 -0300 Subject: [PATCH 3/3] 4.2.6 --- 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 697d418..106a995 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@api-components/api-headers-document", - "version": "4.2.5", + "version": "4.2.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a7afa58..28f4443 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@api-components/api-headers-document", "description": "Documentation component for API headers based on AMF data model", - "version": "4.2.5", + "version": "4.2.6", "license": "Apache-2.0", "main": "index.js", "module": "index.js",