How to use oas-schema-walker - 5 common examples

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 / openapi-codegen / adaptor.js View on Github external
let container = {};
                let model = {};
                model.name = s;
                if (obj.modelNaming === 'snake_case') {
                    model.name = Case.snake(model.name);
                }
                model.classname = model.name;
                model.classVarName = s;
                model.modelJson = safeJson(schema,null,2);
                model.title = schema.title;
                model.unescapedDescription = schema.description;
                model.classFilename = obj.classPrefix+model.name;
                model.modelPackage = model.name;
                model.hasEnums = false;
                model.vars = [];
                walkSchema(schema,{},wsGetState,function(schema,parent,state){
                    let entry = {};
                    entry.name = schema.name || schema.title;
                    if (!entry.name && state.property && (state.property.startsWith('properties') ||
                        state.property.startsWith('additionalProperties'))) {
                        entry.name = state.property.split('/')[1];
                    }
                    if (obj.modelPropertyNaming === 'snake_case') {
                        entry.name = Case.snake(entry.name);
                    }
                    if (reserved.indexOf(entry.name)>=0) {
                        entry.name = Case.pascal(entry.name);
                    }
                    if (entry.name) {
                        entry.baseName = entry.name.toLowerCase();
                    }
                    entry.getter = Case.camel('get_'+entry.name);
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);
}
github Mermade / oas-kit / packages / swagger2openapi / index.js View on Github external
function fixUpSchema(schema,options) {
    sw.walkSchema(schema,{},{},function(schema,parent,state){
        fixUpSubSchemaExtensions(schema,parent);
        fixUpSubSchema(schema,parent,options);
    });
}
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