OpenAPITools / OpenAPITools/openapi-generator

[REQ][kotlin-spring] Use DI to inject business logic into controller

Open
#10,039 2 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.

Currently you have to change the generated implementation of the controller.
If the openapi.json file changes and you regenerate the code, the user code is overwritten.

Describe the solution you'd like

How about injecting a Service Interface into the Controller and the controller just calls this interface.
The Service Interface is also generated by the generator and the user has to write its Business Logic
within its own class which implement that interface. Through the Spring DI the user specifies
which implementation is injected. This separats the generated code from the user code.

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

The issue names the kotlin-spring controller generation but no files, tests, or entry points. Start by locating the kotlin-spring generator templates and its controller generation flow, then assess how a generated service interface and Spring-injected user implementation would fit. Done means generated code can be regenerated without overwriting the user's business logic.

Written by the indexing model from the issue text.

Assessment

Tech stack
kotlin, spring
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.