Skip to content

Commit 061f932

Browse files
Update URL after base uri change (#29)
* fix(api-url): on baseUri change, update url value * 5.1.5
1 parent 80e5903 commit 061f932

File tree

4 files changed

+21
-2
lines changed

4 files changed

+21
-2
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.4",
4+
"version": "5.1.5",
55
"license": "Apache-2.0",
66
"main": "api-method-documentation.js",
77
"keywords": [

src/ApiUrl.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ export class ApiUrl extends AmfHelperMixin(LitElement) {
150150
return this._url || this.baseUri;
151151
}
152152

153+
set baseUri(value) {
154+
const old = this._baseUri;
155+
if (old === value) {
156+
return;
157+
}
158+
this._baseUri = value;
159+
this.requestUpdate('baseUri', old);
160+
this._updateUrl();
161+
}
162+
163+
get baseUri() {
164+
return this._baseUri;
165+
}
166+
153167
render() {
154168
const url = this.url;
155169
return html`

test/api-url.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@ describe('<api-url>', function () {
7878
await nextFrame();
7979
assert.notExists(element.shadowRoot.querySelector('.method-value'));
8080
});
81+
82+
it('should recompute url and keep endpoint path after baseUri change', () => {
83+
element.baseUri = 'http://example.com';
84+
assert.equal(element.url, 'http://example.com/people');
85+
});
8186
});
8287

8388
describe('AsyncAPI', () => {

0 commit comments

Comments
 (0)