How to use the oas-resolver.optionalResolve function in oas-resolver

To help you get started, we’ve selected a few oas-resolver examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Mermade / oas-kit / packages / swagger2openapi / index.js View on Github external
openapi.components.headers = {};
        if (openapi['x-links']) {
            openapi.components.links = openapi['x-links'];
            delete openapi['x-links'];
        }
        openapi.components.parameters = openapi.parameters || {};
        openapi.components.responses = openapi.responses || {};
        openapi.components.requestBodies = {};
        openapi.components.securitySchemes = openapi.securityDefinitions || {};
        openapi.components.schemas = openapi.definitions || {};
        delete openapi.definitions;
        delete openapi.responses;
        delete openapi.parameters;
        delete openapi.securityDefinitions;

        resolver.optionalResolve(options) // is a no-op if options.resolve is not set
        .then(function(){
            main(options.openapi, options);
            if (options.direct) {
                resolve(options.openapi);
            }
            else {
                resolve(options);
            }
        })
        .catch(function(ex){
            console.warn(ex);
            reject(ex);
        });

    }));
}
github Mermade / widdershins / lib / asyncapi1.js View on Github external
function convert(api, options, callback) {
    api = preProcessor(api);

    let defaults = {};
    defaults.includes = [];
    defaults.search = true;
    defaults.theme = 'darkula';
    defaults.language_tabs = [{ 'javascript--nodejs': 'Node.JS' },{ 'javascript': 'JavaScript' }, { 'ruby': 'Ruby' }, { 'python': 'Python' }, { 'java': 'Java' }, { 'go': 'Go'}];

    options = Object.assign({},defaults,options);
    options.openapi = api;

    resolver.optionalResolve(options)
    .then(function(options){
        convertInner(options.openapi, options, callback);
    })
    .catch(function(ex){
        callback(ex);
    });
}
github Mermade / oas-kit / packages / oas-validator / index.js View on Github external
return maybe(callback, new Promise(function (resolve, reject) {
        setupOptions(options,openapi);

        let actions = [];

        resolver.optionalResolve(options)
        .then(function(){
            options.context = [];
            validateSync(openapi, options)
            .then(function(){
                return resolve(options);
            })
            .catch(function(err){
                err.options = options;
                return reject(err);
            });
        })
        .catch(function (err) {
            return reject(err);
        });
    }));
}

oas-resolver

Resolve external $refs in OpenAPI (swagger) 2.0 / 3.x definitions

BSD-3-Clause
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis