Page Contents

Home > @loopback/repository-json-schema > modelToJsonSchema

modelToJsonSchema() function

Converts a TypeScript class into a JSON Schema using TypeScript’s reflection API

Signature:

export declare function modelToJsonSchema<T extends object>(ctor: Function & {
    prototype: T;
}, jsonSchemaOptions?: JsonSchemaOptions<T>): JSONSchema;

Parameters

Parameter Type Description
ctor Function & {
prototype: T;
}
Constructor of class to convert from
jsonSchemaOptions JsonSchemaOptions<T>  

Returns:

JSONSchema