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<T extends object>(modelCtor: Function & {
    prototype: T;
}, options?: JsonSchemaOptions<T>): SchemaRef;

Parameters

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

Returns:

SchemaRef

Example

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