Skip to content

Commit e7d5060

Browse files
authored
Merge pull request #21 from advanced-rest-client/fix/missing-server-description
Fix/missing server description
2 parents 83db825 + 53e56ae commit e7d5060

File tree

8 files changed

+1857
-1405
lines changed

8 files changed

+1857
-1405
lines changed

demo/APIC-641/APIC-641.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
openapi: '3.0.2'
2+
info:
3+
title: 'profiles'
4+
description: >
5+
Provides `profiles` domain services of the **Client Data Platform**.
6+
version: '2.0.1'
7+
contact:
8+
name: Client Data Platform Platform & Support
9+
email: CDP_Services_Support@capgroup.com
10+
url: https://cg-itg.slack.com/archives/C018M7FCSMS/p1602588312007200
11+
servers:
12+
- url: https://api.aws-west-prd.capgroup.com/cdp-proxy/profiles
13+
description: MuleSoft PROD
14+
- url: https://api.aws-west-snp.capgroup.com/cdp-proxy-e2e/profiles
15+
description: MuleSoft UAT (for enterprise consumers)
16+
- url: https://api.aws-west-oz.capgroup.com/cdp-proxy-ite2/profiles
17+
description: MuleSoft QA (for enterprise consumers)
18+
- url: https://api.aws-west-oz.capgroup.com/cdp-proxy-dev2/profiles
19+
paths:
20+
/parties/v1/{partyId}:
21+
summary: Represents a client of Capital Group
22+
description: >
23+
Provides details about Capital Group clients including name, address and other information
24+
get:
25+
operationId: getPartyById
26+
summary: Gets the specific parties in the system.

demo/apis.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@
1111
"google-drive-api/google-drive-api.raml": "RAML 1.0",
1212
"async-api/async-api.yaml": "ASYNC 2.0",
1313
"exchange-experience-api/exchange-experience-api.raml": "RAML 0.8",
14-
"multiple-servers/multiple-servers.yaml": { "type": "OAS 3.0", "mime": "application/yaml" }
14+
"multiple-servers/multiple-servers.yaml": { "type": "OAS 3.0", "mime": "application/yaml" },
15+
"APIC-641/APIC-641.yaml": { "type": "OAS 3.0", "mime": "application/yaml" }
1516
}

demo/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ApiDemo extends ApiDemoPage {
2525
['no-server', 'No server!'],
2626
['multiple-servers', 'Multiple servers'],
2727
['async-api', 'AsyncAPI'],
28+
['APIC-641', 'APIC-641'],
2829
].map(
2930
([file, label]) => html`
3031
<anypoint-item data-src="${file}-compact.json">${label}</anypoint-item>

package-lock.json

Lines changed: 1783 additions & 1381 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 18 additions & 18 deletions
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.0",
4+
"version": "4.6.1",
55
"license": "Apache-2.0",
66
"main": "index.js",
77
"module": "index.js",
@@ -26,28 +26,28 @@
2626
},
2727
"dependencies": {
2828
"@advanced-rest-client/arc-marked": "^1.1.1",
29-
"@advanced-rest-client/markdown-styles": "^3.1.4",
30-
"@api-components/amf-helper-mixin": "^4.3.6",
31-
"@api-components/api-method-documentation": "^5.1.10",
29+
"@advanced-rest-client/markdown-styles": "^3.1.5",
30+
"@api-components/amf-helper-mixin": "^4.3.10",
31+
"@api-components/api-method-documentation": "^5.2.3",
3232
"@api-components/http-method-label": "^3.1.4",
3333
"@api-components/raml-aware": "^3.0.0",
34-
"dompurify": "^2.2.7",
35-
"lit-element": "^2.3.1",
36-
"lit-html": "^1.3.0"
34+
"dompurify": "^2.2.9",
35+
"lit-element": "^2.5.1",
36+
"lit-html": "^1.4.1"
3737
},
3838
"devDependencies": {
3939
"@advanced-rest-client/arc-demo-helper": "^2.2.6",
40-
"@api-components/api-model-generator": "^0.2.8",
41-
"@commitlint/cli": "^12.0.1",
42-
"@commitlint/config-conventional": "^12.0.1",
43-
"@open-wc/eslint-config": "^4.0.1",
44-
"@open-wc/testing": "^2.5.32",
45-
"@types/dompurify": "^2.2.1",
46-
"@web/dev-server": "^0.1.10",
47-
"@web/test-runner": "^0.12.17",
48-
"@web/test-runner-playwright": "^0.8.4",
49-
"eslint": "^7.22.0",
50-
"eslint-config-prettier": "^8.1.0",
40+
"@api-components/api-model-generator": "^0.2.11",
41+
"@commitlint/cli": "^12.1.4",
42+
"@commitlint/config-conventional": "^12.1.4",
43+
"@open-wc/eslint-config": "^4.3.0",
44+
"@open-wc/testing": "^2.5.33",
45+
"@types/dompurify": "^2.2.2",
46+
"@web/dev-server": "^0.1.17",
47+
"@web/test-runner": "^0.13.5",
48+
"@web/test-runner-playwright": "^0.8.6",
49+
"eslint": "^7.28.0",
50+
"eslint-config-prettier": "^8.3.0",
5151
"husky": "^4.3.8",
5252
"lint-staged": "^10.5.4",
5353
"sinon": "^9.2.4",

src/ApiSummary.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,11 @@ export class ApiSummary extends AmfHelperMixin(LitElement) {
397397
_serverListTemplate(server) {
398398
const { baseUri, protocols } = this;
399399
const uri = this._computeBaseUri(server, baseUri, protocols);
400-
return html`<li>${uri}</li>`;
400+
const description = this._computeDescription(server);
401+
return html`<li>
402+
${uri}
403+
<arc-marked .markdown=${description} class="server-description"></arc-marked>
404+
</li>`;
401405
}
402406

403407
/**

src/Styles.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,10 @@ a:hover {
165165
font-weight: 700;
166166
margin: 0.8em 0 0.2em 0;
167167
}
168+
169+
.server-description {
170+
display: block;
171+
font-size: var(--api-summary-server-description-font-size, 12px);
172+
font-weight: var(--api-summary-server-description-font-weight, 600);
173+
}
168174
`;

test/api-summary.test.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,12 @@ describe('ApiSummary', () => {
352352
describe('Server rendering', () => {
353353
let ramlSingleServerAmf;
354354
let oasMultipleServersAmf;
355+
let oasMultipleServersWithDescriptionAmf;
355356
let noServersAmf;
356357
before(async () => {
357358
ramlSingleServerAmf = await AmfLoader.load(compact);
358359
oasMultipleServersAmf = await AmfLoader.load(compact, 'multiple-servers');
360+
oasMultipleServersWithDescriptionAmf = await AmfLoader.load(compact, 'APIC-641');
359361
noServersAmf = await AmfLoader.load(compact, 'no-server');
360362
});
361363

@@ -393,6 +395,20 @@ describe('ApiSummary', () => {
393395
const serversNode = element.shadowRoot.querySelector('.servers');
394396
assert.notOk(serversNode);
395397
});
398+
399+
it('renders multiple URLs with descriptions', async () => {
400+
const element = await modelFixture(oasMultipleServersWithDescriptionAmf);
401+
const nodes = element.shadowRoot.querySelectorAll('.server-lists li');
402+
assert.lengthOf(nodes, 4, 'has 4 servers');
403+
assert.equal(nodes[0].textContent.trim(), 'https://api.aws-west-prd.capgroup.com/cdp-proxy/profiles');
404+
assert.equal(nodes[0].querySelector('arc-marked').markdown, 'MuleSoft PROD');
405+
assert.equal(nodes[1].textContent.trim(), 'https://api.aws-west-snp.capgroup.com/cdp-proxy-e2e/profiles');
406+
assert.equal(nodes[1].querySelector('arc-marked').markdown, 'MuleSoft UAT (for enterprise consumers)');
407+
assert.equal(nodes[2].textContent.trim(), 'https://api.aws-west-oz.capgroup.com/cdp-proxy-ite2/profiles');
408+
assert.equal(nodes[2].querySelector('arc-marked').markdown, 'MuleSoft QA (for enterprise consumers)');
409+
assert.equal(nodes[3].textContent.trim(), 'https://api.aws-west-oz.capgroup.com/cdp-proxy-dev2/profiles');
410+
assert.isUndefined(nodes[3].querySelector('arc-marked').markdown);
411+
});
396412
});
397413

398414
describe('AsyncAPI', () => {
@@ -419,10 +435,6 @@ describe('ApiSummary', () => {
419435

420436
describe('hideToc', () => {
421437
let element = /** @type ApiSummary */ (null);
422-
let amf;
423-
before(async () => {
424-
amf = await AmfLoader.load(compact);
425-
});
426438
beforeEach(async () => {
427439
element = await basicFixture();
428440
element.setAttribute('hideToc', 'true');

0 commit comments

Comments
 (0)