OpenAPITools / OpenAPITools/openapi-generator
[BUG] Missing reserved words in Java and CSharp
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- [x ] Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- [x ] Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- [x ] What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am running into issues in several languages with OAS that are using resource names that are causing conflicts in specific languages. For example, one of the teams is creating a resource called "System". When that generates using the "csharp-netcore" language target. It creates all kinds of problems because System is a reserved word in DotNet. But I don't see System on the reserved word list so I cannot map it to a different name via the command line reserved word mapping.
For Java, I just recently had a team using "OffsetDateTime", "LocalDate" and "LocalTime" as part of their component schemas. Again, this is causing issues when generating against the "java" project as it gets confused and thinks the instances of the class are part of the "java.time" namespace.
openapi-generator version
6.6.0
OpenAPI declaration file content or url
Java Issue:
https://gist.github.com/jwenger100/c6d6bbfaedd63fe9fce645b9d6869016
Csharp-netcore issue:
https://gist.github.com/jwenger100/a6d5238a939deeed43f53de360962adb
Generation Details
Java:
openapi-generator-cli generate -g java
CSharp-Netcore
openapi-generator-cli generate -g csharp-netcore --library=httpclient
Steps to reproduce
- Run the generator command against the OAS provided in the gist above.
- Try to compile the generated code, it will fail.
Related issues/PRs
Suggest a fix
https://github.com/OpenAPITools/openapi-generator/pull/16276
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 reviewing the Java and csharp-netcore generation commands and the two linked OpenAPI gists, then inspect PR #16276 for existing work. Reproduce the generated-code compilation failures and compare the reserved-word handling for System, OffsetDateTime, LocalDate, and LocalTime; done means both generated targets compile without those naming conflicts.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, java, openapi
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100