Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
jsonSchemaOptions: JsonSchemaOptions = {},
): JSONSchema {
const options = {...jsonSchemaOptions};
options.visited = options.visited ?? {};
options.optional = options.optional ?? [];
const partial = options.partial && !options.optional.length;
if (options.partial && !partial) {
debug('Overriding "partial" option with "optional" option');
delete options.partial;
}
debug('Creating schema for model %s', ctor.name);
debug('JSON schema options: %o', options);
const meta: ModelDefinition | {} = ModelMetadataHelper.getModelMetadata(ctor);
// returns an empty object if metadata is an empty object
if (!(meta instanceof ModelDefinition)) {
return {};
}
debug('Model settings', meta.settings);
const title = buildSchemaTitle(ctor, meta, options);
if (options.visited[title]) return options.visited[title];
const result: JSONSchema = {title};
options.visited[title] = result;
const descriptionSuffix = getDescriptionSuffix(options);