Skip to content

Commit 067c03e

Browse files
authored
Merge pull request #33 from advanced-rest-client/fix-url
Fix url
2 parents f67cfb8 + 31cf89f commit 067c03e

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
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-method-documentation",
33
"description": "A HTTP method documentation build from AMF model",
4-
"version": "5.1.7",
4+
"version": "5.1.8",
55
"license": "Apache-2.0",
66
"main": "api-method-documentation.js",
77
"keywords": [

src/ApiUrl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,15 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
191191
}
192192

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

200200
getUrlTemplate() {
201-
const { url, isNotHttp } = this;
202-
if (isNotHttp) {
201+
const { url, isNotHttp, _method } = this;
202+
if (isNotHttp && !!_method) {
203203
return html`<div class="url-server-value"><span class="server-url">Server</span>${url}</div>`
204204
}
205205
return html`${url}`

test/api-url.test.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ describe('<api-url>', function () {
131131

132132
beforeEach(async () => {
133133
const endpointName = 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured'
134-
const [endpoint, operation] = AmfLoader.lookupEndpointOperation(amf, endpointName, 'subscribe');
134+
const [endpoint, operation] = AmfLoader.lookupEndpointOperation(amf, endpointName, 'kafka');
135135
element = await basicFixture();
136136
element.amf = amf;
137137
server = AmfLoader.getEncodes(amf)[element._getAmfKey(element.ns.aml.vocabularies.apiContract.server)];
@@ -152,6 +152,17 @@ describe('<api-url>', function () {
152152
const server = 'Servermqtt://api.streetlights.smartylighting.com:{port}'
153153
assert.equal(element.shadowRoot.querySelector('.url-server-value').textContent, server);
154154
});
155+
156+
it('should only render url value when no operation selected', async () => {
157+
element.amf = amf
158+
element.operation = undefined
159+
element.endpoint = undefined
160+
await nextFrame();
161+
await nextFrame();
162+
163+
const url = 'mqtt://api.streetlights.smartylighting.com:{port}'
164+
assert.equal(element.shadowRoot.querySelector('.url-value').textContent.trim(), url);
165+
});
155166
});
156167
});
157168
});

0 commit comments

Comments
 (0)