OpenAPITools / OpenAPITools/openapi-generator

[REQ] (Optionally) Use LinkedHashMap in Java

Open
#7,242 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.