OpenAPITools / OpenAPITools/openapi-generator
[REQ] [SPRING] Improve constructor generations
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.
Spring constructor can be improved with better support for Jackson and for JSpecify.
Describe the solution you'd like
The Spring generator can generate 3 types of constructors:
- default empty constructor
- constructor for required fields
- constructor for all arguments
We can improve them by adding the @JsonProperty on the fields of the constructors. It is already done in the RestClient.
Adding the @JsonCreator on the all argument constructor to help jackson.
Fix #22757 when using all argument constructors.
Use JSpecify @NullUnmarked on the default constructor to avoid false alarms from code analysis.
Describe alternatives you've considered
custom templates.
Add full support for JSpecify
Additional context
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 Spring generator's handling of its three constructor variants and compare it with the existing RestClient implementation of @JsonProperty. Review the generated output for Jackson and JSpecify behavior; done means the requested constructor annotations are generated and the all-argument constructor addresses #22757 without requiring custom templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100