Skip to content
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
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-method-documentation",
"description": "A HTTP method documentation build from AMF model",
"version": "5.1.7",
"version": "5.1.8",
"license": "Apache-2.0",
"main": "api-method-documentation.js",
"keywords": [
Expand Down
6 changes: 3 additions & 3 deletions src/ApiUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,15 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
}

_getPathTemplate() {
if (this.isNotHttp) {
if (this.isNotHttp && !!this._method) {
return html`<div class="url-channel-value"><span class="channel-url">Channel</span>${this.path}</div>`;
}
return undefined;
}

getUrlTemplate() {
const { url, isNotHttp } = this;
if (isNotHttp) {
const { url, isNotHttp, _method } = this;
if (isNotHttp && !!_method) {
return html`<div class="url-server-value"><span class="server-url">Server</span>${url}</div>`
}
return html`${url}`
Expand Down
13 changes: 12 additions & 1 deletion test/api-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('<api-url>', function () {

beforeEach(async () => {
const endpointName = 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured'
const [endpoint, operation] = AmfLoader.lookupEndpointOperation(amf, endpointName, 'subscribe');
const [endpoint, operation] = AmfLoader.lookupEndpointOperation(amf, endpointName, 'kafka');
element = await basicFixture();
element.amf = amf;
server = AmfLoader.getEncodes(amf)[element._getAmfKey(element.ns.aml.vocabularies.apiContract.server)];
Expand All @@ -152,6 +152,17 @@ describe('<api-url>', function () {
const server = 'Servermqtt://api.streetlights.smartylighting.com:{port}'
assert.equal(element.shadowRoot.querySelector('.url-server-value').textContent, server);
});

it('should only render url value when no operation selected', async () => {
element.amf = amf
element.operation = undefined
element.endpoint = undefined
await nextFrame();
await nextFrame();

const url = 'mqtt://api.streetlights.smartylighting.com:{port}'
assert.equal(element.shadowRoot.querySelector('.url-value').textContent.trim(), url);
});
});
});
});
Expand Down