How to use the oas-kit-common.colour function in oas-kit-common

To help you get started, we’ve selected a few oas-kit-common 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 / oas-validate.js View on Github external
function finalise(err, options) {
    if (!argv.quiet || err) {
        console.warn(common.colour.normal + options.file);
    }
    if (err) {
        console.warn(common.colour.red + options.context.pop() + '\n' + err.message);
        if (err.name.indexOf('ERR_INVALID_URL')>=0) {
            // nop
        }
        else if (err.message.indexOf('schema validation')>=0) {
            if (options.validateSchema !== 'first') {
                warnings.push('Schema fallback '+options.file);
            }
        }
        else if (err.stack && err.name !== 'AssertionError' && err.name !== 'CLIError') {
            console.warn(err.stack);
            warnings.push(err.name+' '+options.file);
        }
        if (options.lintRule && options.lintRule.description !== err.message) {
            console.warn(options.lintRule.description);
        }
        options.valid = (!!options.expectFailure || options.allowFailure);
github Mermade / oas-kit / packages / oas-resolver / index.js View on Github external
recurse(obj, {identityDetection:true}, function (obj, key, state) {
            if (isRef(obj, key)) {
                if (obj[key].startsWith('#')) {
                    if (!seen[obj[key]] && !obj.$fixed) {
                        let target = clone(jptr(context, obj[key]));
                        if (options.verbose>1) console.warn((target === false ? common.colour.red : common.colour.green)+'Fragment resolution', obj[key], common.colour.normal);
                        /*
                            ResolutionCase:A is where there is a local reference in an externally
                            referenced document, and we have not seen it before. The reference
                            is replaced by a copy of the data pointed to, which may be outside this fragment
                            but within the context of the external document
                        */
                        if (target === false) {
                            state.parent[state.pkey] = {}; /* case:A(2) where the resolution fails */
                            if (options.fatal) {
                                let ex = new Error('Fragment $ref resolution failed '+obj[key]);
                                if (options.promise) options.promise.reject(ex)
                                else throw(ex);
                            }
                        }
                        else {
                            changes++;
github Mermade / oas-kit / packages / swagger2openapi / oas-validate.js View on Github external
process.on('exit', function () {
    if (warnings.length) {
        warnings.sort();
        console.warn(common.colour.normal + '\nWarnings:' + common.colour.yellow);
        for (let w in warnings) {
            console.warn(warnings[w]);
        }
    }
    if (failures.length) {
        failures.sort();
        console.warn(common.colour.normal + '\nFailures:' + common.colour.red);
        for (let f in failures) {
            console.warn(failures[f]);
        }
    }
    console.warn(common.colour.normal);
    console.warn('Tests: %s passing, %s failing, %s warnings', pass, fail, warnings.length);
    process.exitCode = ((fail === 0 || options.fail) && (pass > 0)) ? 0 : 1;
});
github Mermade / oas-kit / packages / oas-resolver / index.js View on Github external
.then(function () {
                    if (options.resolver.depth>=options.resolver.actions.length) {
                        console.warn('Ran off the end of resolver actions');
                        return res(true);
                    } else {
                        options.resolver.depth++;
                        if (options.resolver.actions[options.resolver.depth].length) {
                            setTimeout(function () {
                                loopReferences(data.options, res, rej);
                            }, 0);
                        }
                        else {
                            if (options.verbose>1) console.warn(common.colour.yellow+'Finished external resolution!',common.colour.normal);
                            if (options.resolveInternal) {
                                if (options.verbose>1) console.warn(common.colour.yellow+'Starting internal resolution!',common.colour.normal);
                                options.openapi = deRef(options.openapi,options.original,{verbose:options.verbose-1});
                                if (options.verbose>1) console.warn(common.colour.yellow+'Finished internal resolution!',common.colour.normal);
                            }
                            recurse(options.openapi,{},function(obj,key,state){
                                if (isRef(obj, key)) {
                                    if (!options.preserveMiro) delete obj['x-miro'];
                                }
                            });
                            res(options);
                        }
                    }
                })
                .catch(function (ex) {