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(modelCtor: Function, options?: JsonSchemaOptions): JSONSchema;

Parameters

Parameter Type Description
modelCtor Function The model constructor (e.g. Product)
options JsonSchemaOptions Additional options

Returns:

JSONSchema

Example

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