Skip to content

Handle properties in Model Composition - using allOf in OpenAPI #201

@ddobrin

Description

@ddobrin

Properties need to be combined, as per spec:
Inheritance and Polymorphism - Model Composition

In the example below the ExtendedErrorModel schema includes its own properties and properties inherited from BasicErrorModel:

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

Note: current implementation creates a new object as listed under $ref and refers to it in the POJO.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions