Page Contents

Home > @loopback/openapi-v3 > getModelSchemaRef

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

Parameters

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

Returns:

SchemaRef

Example

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