Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (metaProperty.required && !(partial || optional)) {
result.required = result.required ?? [];
result.required.push(p);
}
// populating JSON Schema 'definitions'
// shimks: ugly type casting; this should be replaced by logic to throw
// error if itemType/type is not a string or a function
const resolvedType = resolveType(metaProperty.type) as string | Function;
const referenceType = isArrayType(resolvedType)
? // shimks: ugly type casting; this should be replaced by logic to throw
// error if itemType/type is not a string or a function
resolveType(metaProperty.itemType as string | Function)
: resolvedType;
if (typeof referenceType !== 'function' || isBuiltinType(referenceType)) {
continue;
}
const propSchema = getJsonSchema(referenceType, options);
includeReferencedSchema(referenceType.name, propSchema);
}
result.additionalProperties = meta.settings.strict === false;
debug(' additionalProperties?', result.additionalProperties);
if (options.includeRelations) {
for (const r in meta.relations) {
result.properties = result.properties ?? {};
const relMeta = meta.relations[r];
const targetType = resolveType(relMeta.target);}
result = {type: 'array', items: propDef};
propertyType = meta.itemType as string | Function;
} else {
result = propDef;
}
const wrappedType = stringTypeToWrapper(propertyType);
const resolvedType = resolveType(wrappedType);
if (resolvedType === Date) {
Object.assign(propDef, {
type: 'string',
format: 'date-time',
});
} else if (isBuiltinType(resolvedType)) {
Object.assign(propDef, {
type: resolvedType.name.toLowerCase(),
});
} else {
Object.assign(propDef, {$ref: `#/definitions/${resolvedType.name}`});
}
if (meta.description) {
Object.assign(propDef, {
description: meta.description,
});
}
if (meta.jsonSchema) {
Object.assign(propDef, meta.jsonSchema);
}