Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(W-15520261): show header example when is asyncApi #40

Merged
merged 3 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading