Skip to content

Commit c3f48d4

Browse files
authored
Server name asyncApi26 (#45)
* server name asyncApi26 * 4.6.7
1 parent f65f439 commit c3f48d4

File tree

4 files changed

+48
-4
lines changed

4 files changed

+48
-4
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@api-components/api-summary",
33
"description": "A summary view for an API base on AMF data model",
4-
"version": "4.6.6",
4+
"version": "4.6.7",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",

src/ApiSummary.js

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,10 @@ export class ApiSummary extends AmfHelperMixin(LitElement) {
421421
const { baseUri, protocols } = this;
422422
const uri = this._computeBaseUri(server, baseUri, protocols);
423423
const description = this._computeDescription(server);
424+
const serverNameTemplate = this._serverNameTemplate(server);
424425
const serverTagsTemplate = this._serverTagsTemplate(server);
425426
return html`<li>
426-
${uri} ${serverTagsTemplate}
427+
${serverNameTemplate} ${uri} ${serverTagsTemplate}
427428
<arc-marked
428429
.markdown=${description}
429430
class="server-description"
@@ -447,7 +448,26 @@ export class ApiSummary extends AmfHelperMixin(LitElement) {
447448
(tagName) =>
448449
`#${this._getValue(tagName, this.ns.aml.vocabularies.core.name)} `
449450
);
450-
return tagsNames?.map((t) => html`<p class="server-tag">${t}</p>`);
451+
return tagsNames?.map(
452+
(tagName) => html`<p class="server-tag">${tagName}</p>`
453+
);
454+
}
455+
456+
/**
457+
* @param {any} server Server definition
458+
* @return {TemplateResult} Template for server name
459+
*/
460+
_serverNameTemplate(server) {
461+
const isAsyncApi = this._isAsyncAPI(this.amf);
462+
if (!isAsyncApi) {
463+
return html``;
464+
}
465+
const serverName = this._getValue(
466+
server,
467+
this._getAmfKey(this.ns.aml.vocabularies.core.name)
468+
);
469+
470+
return html`<span class="server-name">${serverName}</span>`
451471
}
452472

453473
/**

src/Styles.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,30 @@ export default css`
166166
margin: 0.8em 0 0.2em 0;
167167
}
168168
169+
.server-name {
170+
color: var(--api-method-documentation-async-server-names-color, #ffffff);
171+
background-color: var(
172+
--api-method-documentation-async-server-names-bg-color,
173+
#506773
174+
);
175+
text-align: center;
176+
font-family: var(
177+
--api-method-documentation-async-server-names-font,
178+
Avenir
179+
);
180+
font-size: 14px;
181+
font-style: normal;
182+
font-weight: 500;
183+
line-height: normal;
184+
border-radius: 4px;
185+
border: 1px solid
186+
var(--api-method-documentation-async-server-names-border-color, #506773);
187+
padding: 1px 8px 1px 8px;
188+
margin-right: 10px;
189+
word-break: auto-phrase;
190+
max-width: fit-content;
191+
}
192+
169193
.server-tag {
170194
display: inline-block;
171195
border: 1px solid var(--anypoint-color-coreBlue2);

0 commit comments

Comments
 (0)