in src/generator.ts [177:211]
function propertyType(prop: any): string {
if (prop.$ref) {
return getRef(prop.$ref);
}
if (Array.isArray(prop.oneOf)) {
return (prop.oneOf as any[]).map(t => propertyType(t)).join(' | ')
}
switch (prop.type) {
case 'array':
const s = propertyType(prop.items);
if (s.indexOf(' ') >= 0) {
return `(${s})[]`;
}
return `${s}[]`;
case 'object':
return objectType(prop);
case 'string':
if (prop.enum) {
return enumAsOrType(prop.enum);
} else if (prop._enum) {
return enumAsOrType(prop._enum, true);
}
return `string`;
case 'integer':
return 'number';
}
if (Array.isArray(prop.type)) {
if (prop.type.length === 7 && prop.type.sort().join() === 'array,boolean,integer,null,number,object,string') { // silly way to detect all possible json schema types
return 'any';
} else {
return prop.type.map(v => v === 'integer' ? 'number' : v).join(' | ');
}
}
return prop.type;
}