Selected value for discriminator field doesn't make sense if response is a subschema
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 25.9k
- Forks
- 2.4k
- Avg merge
- 13h 10m
- Merged PRs (30d)
- 4
Description
For the PetStore example, if I add an endpoint to return a Dog by Id and reference Pet's subschema Dog, I would expect the generated doc has Dog for the response schema. However, it is still showing Pet as the response type and default the selection to Cat. This is very confusing. As we already know its strong type, shouldn't it point to the correct value (and disable the dropbox ideally)?
Endpoint added:
'/dog/{dogId}':
get:
tags:
- pet
summary: Find dog by ID
description: Returns a single dog
operationId: getDogById
parameters:
- name: dogId
in: path
description: ID of dog to return
required: true
deprecated: true
schema:
type: integer
format: int64
responses:
'200':
description: successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Dog'
application/xml:
schema:
$ref: '#/components/schemas/Dog'
'400':
description: Invalid ID supplied
'404':
description: Dog not found
security:
- api_key: []
Generated UI

Expected UI

I'm not too worried about it if only discriminator field is populated wrongly. But it actually renders other Cat specific fields and ignores Dog specific fields. This makes it unacceptable to release the documentation to our customers.
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 with the PetStore example and reproduce the generated UI using the /dog/{dogId} response schema reference to Dog. Trace how the response schema's discriminator selection is rendered when it is a subschema of Pet. Done means the UI selects Dog, does not default to Cat, and renders Dog-specific fields instead of Cat-specific fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- api, documentation, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100