Skip to content

Commit

Permalink
Merge pull request #40 from advanced-rest-client/feat/W-15520261/asyn…
Browse files Browse the repository at this point in the history
…c-api-examples

feat(W-15520261): show header example when is asyncApi
  • Loading branch information
leandrogilcarrano authored Apr 22, 2024
2 parents baad05f + f47b018 commit 9e50ace
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
9 changes: 8 additions & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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`
<anypoint-item data-src="${file}-compact.json">${label} - compact model</anypoint-item>
<anypoint-item data-src="${file}.json">${label}</anypoint-item>
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 8 additions & 2 deletions src/ApiHeadersDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,9 @@ 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);

return html`<style>${this.styles}</style>
<section class="headers">
<div
Expand All @@ -107,7 +108,7 @@ export class ApiHeadersDocument extends LitElement {
?narrow="${narrow}"
?graph="${graph}"
noExamplesActions
noMainExample
?noMainExample="${noMainExample}"
></api-type-document>` :
html`<p class="no-info">Headers are not required by this endpoint</p>`}
</anypoint-collapse>
Expand Down Expand Up @@ -153,6 +154,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 },
};
}

Expand All @@ -167,6 +172,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.
Expand Down

0 comments on commit 9e50ace

Please sign in to comment.