fix: crash if contact is not in the spec

closes #332
This commit is contained in:
Roman Hotsiy 2017-08-28 13:24:09 +03:00
parent dd6dfa1f1a
commit 35176b5f67
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0
2 changed files with 4 additions and 4 deletions

View File

@ -39,6 +39,7 @@ info:
termsOfService: 'http://swagger.io/terms/'
contact:
email: apiteam@swagger.io
url: https://github.com/Rebilly/ReDoc
x-logo:
url: 'https://rebilly.github.io/ReDoc/petstore-logo.png'
license:

View File

@ -16,13 +16,12 @@ export class ApiLogo extends BaseComponent implements OnInit {
}
init() {
let logoInfo = this.componentSchema.info['x-logo'];
if ('url' in this.componentSchema.info['contact']) {
this.logo.url = this.componentSchema.info['contact']['url'];
}
const info = this.componentSchema.info;
const logoInfo = info['x-logo'];
if (!logoInfo) return;
this.logo.imgUrl = logoInfo.url;
this.logo.bgColor = logoInfo.backgroundColor || 'transparent';
this.logo.url = info.contact && info.contact.url || null;
}
ngOnInit() {