Skip to content

Instantly share code, notes, and snippets.

@MathRobin

MathRobin/index.js

Created Oct 31, 2019
Embed
What would you like to do?
object to json oas
function doc (obj){
var res = {};
_.each(obj, function (val, key) {
if(_.isArray(val)) {
res[key] = {"type": "array", items:{type:"object","properties": doc(val)}};
} else if(_.isObject(val)) {
res[key] = {"type": "object","properties": doc(val)};
} else if(_.isString(val)){
res[key] = {type:'string'};
} else if(_.isInteger(val)){
res[key] = {type:'integer'};
} else if(_.isNumber(val)){
res[key] = {type:'number'};
}
});
return res;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.