Open

Description
I have a base schema Pet
with a discriminant petType
and some schemas Cat
, Dog
and Lizard
that inherit from it. When I use the Pet
schema in documentation, I get the dropdown for petType
as expected with each of the different types, but when I use the Cat
type I also get the same, despite petType: "Cat"
being the only valid value for this.
These are the types I get (first Pet
and then Cat
):
For the second one, I'd expect something like this instead:
These are the files that I'm using for this test case:
openapi: 3.0.2
info:
title: Test API
version: playground
servers: []
paths:
/pets:
get:
summary: "Get all pets"
responses:
200:
description: ""
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/Pet"
/cats:
get:
summary: "Get all cats"
responses:
200:
description: ""
content:
application/json:
schema:
type: object
properties:
items:
type: array
items:
$ref: "#/components/schemas/Cat"
components:
schemas:
Pet:
type: object
description: "Pet superclass"
required:
- petType
properties:
petType:
type: string
description: "Pet type"
discriminator:
propertyName: petType
Cat:
description: "Cat subclass"
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Cat`
properties:
name:
description: "Name"
type: string
Dog:
description: "Dog subclass"
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Dog`
properties:
bark:
description: "Bark"
type: string
Lizard:
description: "Lizard subclass"
allOf:
- $ref: "#/components/schemas/Pet"
- type: object
# all other properties specific to a `Lizard`
properties:
lovesRocks:
description: "Loves rocks"
type: boolean