fix: do not crash if version is not string

closes #208
This commit is contained in:
Roman Hotsiy 2017-02-26 00:44:21 +02:00
parent 9d0dd25f30
commit accd01659d
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@ export class ApiInfo extends BaseComponent implements OnInit {
init() { init() {
this.info = this.componentSchema.info; this.info = this.componentSchema.info;
this.specUrl = this.optionsService.options.specUrl; this.specUrl = this.optionsService.options.specUrl;
if (!isNaN(parseInt(this.info.version.substring(0, 1)))) { if (!isNaN(parseInt(this.info.version.toString().substring(0, 1)))) {
this.info.version = 'v' + this.info.version; this.info.version = 'v' + this.info.version;
} }
} }

View File

@ -83,7 +83,7 @@ export class SpecManager {
preprocess() { preprocess() {
let mdRender = new MdRenderer(); let mdRender = new MdRenderer();
if (!this._schema.info) { if (!this._schema.info) {
throw 'Required field "info" is not specified at the spec top level'; throw Error('Specification Error: Required field "info" is not specified at the top level of the specification');
} }
if (!this._schema.info.description) this._schema.info.description = ''; if (!this._schema.info.description) this._schema.info.description = '';
if (this._schema.securityDefinitions) { if (this._schema.securityDefinitions) {