swagger-api / swagger-api/swagger-codegen
Invalid generation of JSON discriminator
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
"CallResult" : {
"allOf" : [
{"$ref" : "#/components/schemas/GeneralObject"},
]
}
as even it is not possible to use:
"CallResult" : {"$ref" : "#/components/schemas/GeneralObject"}
Tested in context of : "library" set to "okhttp-gson".
It is not possible to realized a case when result could be change or enhanced in future, but you would like to avoid code rewriting as this always generate discriminator even it is known a exact class of response to that it should be deserialized so no discriminator (Type Selector, ...) is needed at all.
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 reproducing the issue with the okhttp-gson library and the shown CallResult schema using allOf and a GeneralObject reference. Trace the generator's discriminator handling for this schema and compare it with a direct $ref. Done means the generated response avoids an unnecessary discriminator when its exact class is known, while preserving future extension behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100