OAS:OpenAPI Editor/Composite Schemas
The OpenAPI Specification allows combining and extending model definitions, in effect offering model composition.
Example of a composite schema. oneOf in this example takes an array of object definitions. A response payload MAY be described to be exactly one and only one of them:
... components: schemas: Pet: ... oneOf: - $ref: '#/components/schemas/Bird' - $ref: '#/components/schemas/Bunny' - $ref: '#/components/schemas/Cat' ...
To combine schemas using specs' keywords anyOf, allOf, oneOf or not. That is, add a subschema to an existing schema (making it composite), right-click a schema then select Add Sub-Schema from the popup menu.
Then fill in the wizard you're prompted with. You don't have to fill in the name if you merely want to add an existing schema as subschema (That is, you picked an existing schema as type from the drop-down box beside the Type label).
Please note that if you fill in the name of the subschema you're about to add, then a new schema will always be created, added to the components/schemas section. then added as subschema. This comes handy if you wat to create a new schema then refer it from a composite one in one go.
Then hit Finish.
Change Sub-Schema (composite) Keyword
The relation between a composite schema and its subschemas is specified by these keywords anyOf, allOf, oneOf and not.
To interchange between relations specified by anyOf, allOf, oneOf. Click the composite keyword (as shown below) then select a new relation from the Change To submenu.