Page Contents

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

getJsonSchemaRef() function

Describe the provided Model as a reference to a definition shared by multiple endpoints. The definition is included in the returned schema.

Signature:

export declare function getJsonSchemaRef<T extends object>(modelCtor: Function & {
    prototype: T;
}, options?: JsonSchemaOptions<T>): JSONSchema;

Parameters

Parameter Type Description
modelCtor Function & {
prototype: T;
}
The model constructor (e.g. Product)
options JsonSchemaOptions<T> Additional options

Returns:

JSONSchema

Example

const schema = {
  $ref: '/definitions/Product',
  definitions: {
    Product: {
      title: 'Product',
      properties: {
        // etc.
      }
    }
  }
}