OpenAPITools / OpenAPITools/openapi-generator
[REQ] [Java] Migration to java-specific code model for SpringCodeGen.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.
The current situation is that a lot of logic has been accumulated in mustache templates. As mustache templates are logic-less and restrictive, it is really really hard to understand what is going on out there. As an example, take a look at this and tell me that it is sane programming:
https://raw.githubusercontent.com/OpenAPITools/openapi-generator/master/modules/openapi-generator/src/main/resources/JavaSpring/queryParams.mustache
Describe the solution you'd like
This situation has happened for one reason, mustache templates have generic code model. Because it is too generic, a lot of logic is put in those templates, which is, in my opinion, a tough idea since mustache templates are restrictive.
My proposal is to narrow the model down to the most specific cases. Introduce such things as "annotation" and "method arguments" which could accumulate the whole logic behind them. And stop using conditionals in mustache templates as much as possible.
Describe alternatives you've considered
Don't see any other solutions.
Migrating to a different template engine won't make much of a difference in my opinion since it doesn't introduce a notion of a model in DDD sense. We all know what happens with a project if the domain logic lies in a view layer, guys.
Additional context
I'm not trying to blame someone. If I mistakenly led you into this idea, I am sorry. English is not my first language. Tell me and I will correct my writing.
All I want to do is to raise an awareness and cooperate with someone in order to make a big refactoring.
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 reading SpringCodeGen.java and the JavaSpring queryParams.mustache template linked in the issue to understand where the current generic model drives template conditionals. The proposed work is complete when Java-specific concepts such as annotations and method arguments carry that logic, substantially reducing conditionals in the mustache templates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend-api-design, tooling
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100