Discriminator dropdown shown for all variants
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by loading the supplied OpenAPI 3.0.2 Pet/Cat example and compare the discriminator dropdown rendered for Pet with the one rendered for Cat. Trace the documentation schema-rendering entry point that produces these controls; done means the Cat view presents only its valid discriminator value rather than the full Pet variant list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100