OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] When using java and library native I get syntax error
Nobody has claimed this yet.
- 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
When trying to generate .java files from Unleash OpenAPI specs (file attached), I get errors using OpenAPI Generator with java native library. It seems that it generates the method names that are not valid for Java syntax. I use java native because I want the client to be java.net.http.HttpClient.
Command I use:
openapi-generator generate -i unleash.openapi.json -g java -o test --additional-properties=serializationLibrary=jackson,library=native
Example error I get when I try to compile the code:
.../AdvancedPlaygroundRequestSchemaProjects.java:228: error: unexpected token: <
public List<String> getList<String>() throws ClassCastException {
^
Multiple files have this issue.
openapi-generator version
7.17.0
OpenAPI declaration file content or url
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 running the reported openapi-generator command with the attached unleash.openapi.json and inspect the generated AdvancedPlaygroundRequestSchemaProjects.java and other failing files. Compare the generated accessor names with valid Java syntax; done means the native Java client generated from this specification compiles without syntax errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100