OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Core] anyOf/oneOf marks union of required fields as required, should be intersection
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
The merged composed model from anyOf / oneOf adds every member's required fields to required. A field is only guaranteed present if every member requires it, so the merged set should be the intersection. Affects every generator that uses CodegenModel.required (Swift, Kotlin, Java POJOs, Dart, etc.).
response:
anyOf:
- $ref: '#/components/schemas/VoteResponse' # required: [status, voteId]
- $ref: '#/components/schemas/APIError' # required: [status, reason, code]
Currently the generator marks status, voteId, reason, code all required; only status is. Working on a PR.
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 in the composed-model logic that populates CodegenModel.required, then trace how affected generators consume that field. Reproduce the VoteResponse/APIError anyOf example and verify that only fields required by every member remain required across the relevant generated outputs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, java, kotlin, swift
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100