OpenAPITools / OpenAPITools/openapi-generator
[REQ] Supporting guava's Immutable Collections in Java codegen
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.
Using immutable data structures is quite valuable when writing multi-threaded code, and I think it would be a great improvement to the current generated code if it supported generating immutable models and APIs.
Describe the solution you'd like
The end goal would be to add a CLI option to generate models/APIs which use guava's Immutable types, have no setters, and include generated builders. The first step I see is to initially add support for using guava's immutable collections, and future iterations may update templates to optionally remove getters and generate builders.
Describe alternatives you've considered
The only alternative I can think of is manually writing immutable wrappers for each generated model (per-project), which essentially defeats the purpose of generating code. At my workplace we used a similar solution with manually writing immutable wrappers, and we have since transitioned to generating immutable models.
Additional context
I've written up a proof-of-concept PR which adds support for generating code with guava's immutable collections, and wrote up more information about the implementation and hardships there.
https://github.com/OpenAPITools/openapi-generator/pull/5826
I'm curious to learn what the community thinks about improving support for immutable generated code.
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 proof-of-concept pull request #5826 and the proposed first step in this issue. The initial scope is support for Guava immutable collections in generated Java models and APIs; the broader CLI option, builder generation, and setter changes are described as future iterations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100