OpenAPITools / OpenAPITools/openapi-generator
[REQ] (Optionally) Use LinkedHashMap in Java
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Although JSON is technically unordered, it is useful to have a predictable serialization order, such as for display sorting. The generateAliasAsModel option on Java uses HashMap, which will reorder the properties. Instead, using LinkedHashMap would have a minimal performance impact but provide consistent ordering.
Describe the solution you'd like
I suggest modifying all of the HashMap references to use LinkedHashMap.
Describe alternatives you've considered
LinkedHashMap is slightly less efficient, but many tools (e.g., the entire Groovy platform) use it by default specifically for the convenience of predictable ordering. If the efficiency is a major problem, it could be made optional.
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 locating the Java generator path that handles the generateAliasAsModel option and inspect its HashMap references. Check how generated properties are currently ordered, then verify that the requested behavior is consistent and predictable when the option is enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100