OpenAPITools / OpenAPITools/openapi-generator
[BUG] Description Invalid code generated in Java for oneof on types than end up with generics
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Invalid code generation for oneof in Java.
openapi-generator version
v7.16.0
OpenAPI declaration file content or url
"someField": {
"oneOf": [
{
"type": "array",
"items": {
"type": "string"
},
},
{
"type": "string",
"enum": [
"*"
],
}
]
},
Generation Details
Will generate the following invalid code
public List<String> getList<String>() throws ClassCastException {
...
}
The name of the method should be just getList and not getList<String>
Suggest a fix
The signature of the generated code should be
public List<String> getList() throws ClassCastException {
...
}
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 provided oneOf declaration using OpenAPI Generator v7.16.0, then trace the Java generation path that derives the getter name for the array/string alternatives. Done means the generated signature uses getList() while retaining List as its return type, without invalid generic text in the method name.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100