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/' termsOfService: 'http://swagger.io/terms/'
contact: contact:
email: apiteam@swagger.io email: apiteam@swagger.io
url: https://github.com/Rebilly/ReDoc
x-logo: x-logo:
url: 'https://rebilly.github.io/ReDoc/petstore-logo.png' url: 'https://rebilly.github.io/ReDoc/petstore-logo.png'
license: license:

View File

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