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);
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);
});
}