index.js
function swaggerSecurity(context, headers) {
    var security = null;
    headers.filter(function(header) {
        return header.name.toLowerCase() === 'authorization';
    }).forEach(function(header) {
        if (header.value.match(/^Basic /)) {
            if (!security) security = {};
            security['basic'] = [];
            context.swagger.securityDefinitions['basic'] = { type: 'basic' };
        } else if (header.value.match(/^Bearer /)) {
            if (!security) security = {};
            if (context.options.bearerAsApikey) {
                security['bearer'] = [];
                context.swagger.securityDefinitions['bearer'] = {
                    type: 'apiKey', in: 'header', name: 'Authorization'
                };
            } else {
                security['oauth2'] = [];
                context.swagger.securityDefinitions['oauth2'] = {
                    type: 'oauth2', flow: 'accessCode',
                    authorizationUrl: '', tokenUrl: '', scopes: {} };
            }
        }
    });
    return security;
}
function swaggerSecurity(context, headers) {
    var security = null;
    headers.filter(function(header) {
        return header.name.toLowerCase() === 'authorization';
    }).forEach(function(header) {
        if (header.value.match(/^Basic /)) {
            if (!security) security = {};
            security['basic'] = [];
            context.swagger.securityDefinitions['basic'] = { type: 'basic' };
        } else if (header.value.match(/^Bearer /)) {
            if (!security) security = {};
            if (context.options.bearerAsApikey) {
                security['bearer'] = [];
                context.swagger.securityDefinitions['bearer'] = {
                    type: 'apiKey', in: 'header', name: 'Authorization'
                };
            } else {
                security['oauth2'] = [];
                context.swagger.securityDefinitions['oauth2'] = {
                    type: 'oauth2', flow: 'accessCode',
                    authorizationUrl: '', tokenUrl: '', scopes: {} };
            }
        }
    });
    return security;
}
function swaggerSecurity ( context , headers ) { var security = null ; headers . filter ( function ( header ) { return header . name . toLowerCase ( ) === 'authorization' ; } ) . forEach ( function ( header ) { if ( header . value . match ( / ^Basic  / ) ) { if ( ! security ) security = { } ; security [ 'basic' ] = [ ] ; context . swagger . securityDefinitions [ 'basic' ] = { type : 'basic' } ; } else if ( header . value . match ( / ^Bearer  / ) ) { if ( ! security ) security = { } ; if ( context . options . bearerAsApikey ) { security [ 'bearer' ] = [ ] ; context . swagger . securityDefinitions [ 'bearer' ] = { type : 'apiKey' , in : 'header' , name : 'Authorization' } ; } else { security [ 'oauth2' ] = [ ] ; context . swagger . securityDefinitions [ 'oauth2' ] = { type : 'oauth2' , flow : 'accessCode' , authorizationUrl : '' , tokenUrl : '' , scopes : { } } ; } } } ) ; return security ; }
generate security and securityDefinitions from authorization headers
generate security and securityDefinitions from authorization headers