Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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 = '';
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);
}
function fixUpSchema(schema,options) {
sw.walkSchema(schema,{},{},function(schema,parent,state){
fixUpSubSchemaExtensions(schema,parent);
fixUpSubSchema(schema,parent,options);
});
}
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);
}