fix: do not auto-append security-definitions if they are not in the spec

This commit is contained in:
Roman Hotsiy 2017-11-24 11:49:32 +02:00
parent ca81b6dfaf
commit 426e5b67ab
No known key found for this signature in database
GPG Key ID: 5CB7B3ACABA57CB0

View File

@ -68,7 +68,12 @@ export class OpenAPIParser {
} }
preprocess(spec: OpenAPISpec) { preprocess(spec: OpenAPISpec) {
if (!this.options.noAutoAuth && spec.info) { if (
!this.options.noAutoAuth &&
spec.info &&
spec.components &&
spec.components.securitySchemes
) {
// Automatically inject Authentication section with SecurityDefinitions component // Automatically inject Authentication section with SecurityDefinitions component
const description = spec.info.description || ''; const description = spec.info.description || '';
const securityRegexp = new RegExp( const securityRegexp = new RegExp(