How to use the oas-schema-walker.walkSchema 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 / 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 / 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);
    });
}

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