openapi: 3.1.0 info: title: anyOf / oneOf example description: Demonstrate the anyOf and oneOf issue version: 1.0.0 paths: /animals/{id}: get: summary: Find animal by ID description: Returns a single animal operationId: getAnimalByID parameters: - name: id in: path description: ID of animal to get schema: type: string required: true example: "10" responses: "200": description: successful operation content: "application/json": schema: oneOf: - $ref: '#/components/schemas/Cat' - $ref: '#/components/schemas/Dog' discriminator: propertyName: petType required: - petType "400": description: Invalid ID supplied content: {} "404": description: Animal not found content: {} components: schemas: Pet: type: object required: - name properties: name: type: string Dog: properties: petType: const: Dog # "Dog" is a value for the petType property (the discriminator value) allOf: # Combines the main `Pet` schema with `Dog`-specific properties - $ref: '#/components/schemas/Pet' - type: object # all other properties specific to a `Dog` properties: bark: type: boolean breed: type: string enum: [Dingo, Husky, Retriever, Shepherd] Cat: properties: petType: const: Cat # "Cat" is a value for the petType property (the discriminator value) allOf: # Combines the main `Pet` schema with `Cat`-specific properties - $ref: '#/components/schemas/Pet' - type: object # all other properties specific to a `Cat` properties: hunts: type: boolean age: type: integer