Description

In OpenAPI version 3, you do this with the allOf keyword:

components:
  schemas:
    BasicErrorModel:
      type: object
      required:
        - message
        - code
      properties:
        message:
          type: string
        code:
          type: integer
          minimum: 100
          maximum: 600
    ExtendedErrorModel:
      allOf:     # Combines the BasicErrorModel and the inline model
        - $ref: '#/components/schemas/BasicErrorModel'
        - type: object
          required:
            - rootCause
          properties:
            rootCause:
              type: string

In the example above, the ExtendedErrorModel schema includes its own properties and properties inherited from BasicErrorModel

Preview

Tags

Users

  • @jil

Comments and Reviews