Skip to content

Commit

Permalink
fix: don't show download button if initialized with an object
Browse files Browse the repository at this point in the history
  • Loading branch information
RomanHotsiy committed Apr 23, 2017
1 parent 0f6f035 commit 476d6c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/components/ApiInfo/api-info.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="api-info-wrapper">
<h1>{{info.title}} <span class="api-info-version">({{info.version}})</span></h1>
<p>
<p class="donwload-openapi" *ngIf="specUrl">

This comment has been minimized.

Copy link
@dwilding

dwilding Apr 25, 2017

Hey, should the class name be download-openapi (typo)?

This comment has been minimized.

Copy link
@RomanHotsiy

RomanHotsiy Apr 25, 2017

Author Member

@dwilding sure! Thanks for catch!

Download OpenAPI (fka Swagger) specification:
<a class="openapi-button" target="_blank" attr.href='{{specUrl}}'> Download </a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion lib/components/ApiInfo/api-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class ApiInfo extends BaseComponent implements OnInit {

init() {
this.info = this.componentSchema.info;
this.specUrl = this.optionsService.options.specUrl;
this.specUrl = this.specMgr.specUrl;
if (!isNaN(parseInt(this.info.version.toString().substring(0, 1)))) {
this.info.version = 'v' + this.info.version;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/utils/spec-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class SpecManager {
public basePath: string;

public spec = new BehaviorSubject<any|null>(null);
public _specUrl: string;
public specUrl: string;
private parser: any;
private options: Options;

Expand All @@ -46,7 +46,7 @@ export class SpecManager {
this.parser.bundle(urlOrObject, {http: {withCredentials: false}})
.then(schema => {
if (typeof urlOrObject === 'string') {
this._specUrl = urlOrObject;
this.specUrl = urlOrObject;
}
this._schema = snapshot(schema);
try {
Expand All @@ -64,7 +64,7 @@ export class SpecManager {

/* calculate common used values */
init() {
let urlParts = this._specUrl ? urlParse(urlResolve(window.location.href, this._specUrl)) : {};
let urlParts = this.specUrl ? urlParse(urlResolve(window.location.href, this.specUrl)) : {};
let schemes = this._schema.schemes;
let protocol;
if (!schemes || !schemes.length) {
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/SpecManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ describe('Utils', () => {

it('should substitute api scheme when spec schemes are undefined', () => {
specMgr._schema.schemes = undefined;
specMgr._specUrl = 'https://petstore.swagger.io/v2';
specMgr.specUrl = 'https://petstore.swagger.io/v2';
specMgr.init();
specMgr.apiUrl.should.be.equal('https://petstore.swagger.io/v2');
});

it('should substitute api host when spec host is undefined', () => {
specMgr._schema.host = undefined;
specMgr._specUrl = 'http://petstore.swagger.io/v2';
specMgr.specUrl = 'http://petstore.swagger.io/v2';
specMgr.init();
specMgr.apiUrl.should.be.equal('http://petstore.swagger.io/v2');
});

it('should use empty basePath when basePath is not present', () => {
specMgr._schema.basePath = undefined;
specMgr._specUrl = 'https://petstore.swagger.io';
specMgr.specUrl = 'https://petstore.swagger.io';
specMgr.init();
specMgr.basePath.should.be.equal('');
});
Expand Down

0 comments on commit 476d6c4

Please sign in to comment.