How to use the oas-schema-walker.getDefaultState function in oas-schema-walker

To help you get started, we’ve selected a few oas-schema-walker 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 / widdershins / lib / common.js View on Github external
let oDepth = 0;
    let blockDepth = 0;
    let skipDepth = -1;
    let container = [];
    let depthQueue = new Map();
    let block = { title: '', rows: [] };
    if (schema) {
        if (schema.title) block.title = schema.title;
        if (!block.title && schema.description)
            block.title = schema.description;
        block.description = schema.description;
        if (schema.externalDocs)
            block.externalDocs = schema.externalDocs;
    }
    container.push(block);
    let wsState = wsGetState();
    wsState.combine = true;
    wsState.allowRefSiblings = true;
    walkSchema(schema,{},wsState,function(schema,parent,state){

        let isBlock = false;
        if (state.property && (state.property.startsWith('allOf') || state.property.startsWith('anyOf') || state.property.startsWith('oneOf') || (state.property === 'not'))) {
            isBlock = true;
            let components = (state.property+'/0').split('/');
            if (components[1] !== '0') {
                if (components[0] === 'allOf') components[0] = 'and';
                if (components[0] === 'anyOf') components[0] = 'or';
                if (components[0] === 'oneOf') components[0] = 'xor';
            }
            block = { title: components[0], rows: [] };
            let dschema = schema;
            let prefix = '';
github Mermade / oas-kit / packages / oas-validator / index.js View on Github external
function checkSchema(schema,parent,prop,openapi,options) {
    let state = sw.getDefaultState();
    state.openapi = openapi;
    state.options = options;
    state.property = prop;
    sw.walkSchema(schema,parent,state,checkSubSchema);
}

oas-schema-walker

Library to walk OAS 3 schema objects and call a callback

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

71 / 100
Full package analysis