swagger-api / swagger-api/swagger-core
@Schema oneOf config is ignored when generate the api-docs
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 7.5k
- Forks
- 2.3k
- Avg merge
- 18h 1m
- Merged PRs (30d)
- 10
Description
@Schema(oneOf = {Child1.class, Child2.class})
private Parent obj;
The result is something like this
"MyPojo": {
"oneOf": [
{
"$ref": "#/components/schemas/Child1"
},
{
"$ref": "#/components/schemas/Child2"
},
{
"$ref": "#/components/schemas/Child3"
}
]
},
Seems the result does not come from my config.
Also I think oneOf should take string($ref) instead class?
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
Use the Java @Schema(oneOf = {Child1.class, Child2.class}) example as a reproducer and trace how the schema generator combines annotation configuration with discovered subtypes. Compare the generated api-docs output with the declared classes, including whether Child3 is added and how oneOf references are represented. Done means the configured oneOf behavior is covered and the generated output matches the intended references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100