Skip to content

Commit 476d6c4

Browse files
committed
fix: don't show download button if initialized with an object
1 parent 0f6f035 commit 476d6c4

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/components/ApiInfo/api-info.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="api-info-wrapper">
22
<h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
3-
<p>
3+
<p class="donwload-openapi" *ngIf="specUrl">
44
Download OpenAPI (fka Swagger) specification:
55
<a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a>
66
</p>

lib/components/ApiInfo/api-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class ApiInfo extends BaseComponent implements OnInit {
2323

2424
init() {
2525
this.info = this.componentSchema.info;
26-
this.specUrl = this.optionsService.options.specUrl;
26+
this.specUrl = this.specMgr.specUrl;
2727
if (!isNaN(parseInt(this.info.version.toString().substring(0, 1)))) {
2828
this.info.version = 'v' + this.info.version;
2929
}

lib/utils/spec-manager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class SpecManager {
3232
public basePath: string;
3333

3434
public spec = new BehaviorSubject<any|null>(null);
35-
public _specUrl: string;
35+
public specUrl: string;
3636
private parser: any;
3737
private options: Options;
3838

@@ -46,7 +46,7 @@ export class SpecManager {
4646
this.parser.bundle(urlOrObject, {http: {withCredentials: false}})
4747
.then(schema => {
4848
if (typeof urlOrObject === 'string') {
49-
this._specUrl = urlOrObject;
49+
this.specUrl = urlOrObject;
5050
}
5151
this._schema = snapshot(schema);
5252
try {
@@ -64,7 +64,7 @@ export class SpecManager {
6464

6565
/* calculate common used values */
6666
init() {
67-
let urlParts = this._specUrl ? urlParse(urlResolve(window.location.href, this._specUrl)) : {};
67+
let urlParts = this.specUrl ? urlParse(urlResolve(window.location.href, this.specUrl)) : {};
6868
let schemes = this._schema.schemes;
6969
let protocol;
7070
if (!schemes || !schemes.length) {

tests/unit/SpecManager.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ describe('Utils', () => {
4646

4747
it('should substitute api scheme when spec schemes are undefined', () => {
4848
specMgr._schema.schemes = undefined;
49-
specMgr._specUrl = 'https://petstore.swagger.io/v2';
49+
specMgr.specUrl = 'https://petstore.swagger.io/v2';
5050
specMgr.init();
5151
specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2');
5252
});
5353

5454
it('should substitute api host when spec host is undefined', () => {
5555
specMgr._schema.host = undefined;
56-
specMgr._specUrl = 'http://petstore.swagger.io/v2';
56+
specMgr.specUrl = 'http://petstore.swagger.io/v2';
5757
specMgr.init();
5858
specMgr.apiUrl.should.be.equal('http://petstore.swagger.io/v2');
5959
});
6060

6161
it('should use empty basePath when basePath is not present', () => {
6262
specMgr._schema.basePath = undefined;
63-
specMgr._specUrl = 'https://petstore.swagger.io';
63+
specMgr.specUrl = 'https://petstore.swagger.io';
6464
specMgr.init();
6565
specMgr.basePath.should.be.equal('');
6666
});

0 commit comments

Comments
 (0)