OpenAPITools / OpenAPITools/openapi-generator

[REQ] [JAVA] [resttemplate] [webclient] option to disable auto instantiation of Components

Open
#13,362 1 comment 2 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.

I'm using openapi-generator to generate a lib (not an app) with continuous integration of an API definition. The issue is that my lib must provide multiple clients of the same API with different basePath and dynamically generated headers. I can't rely on the autowired components generated because there is only one ApiClient and one suite of APIs instanciated. Also ApiClient takes the default RestTemplate bean in the ApplicationContext meaning no API specific header is possible without conflict issues. This last part is quite problematic as it applies for any project that would need multiple ApiClient within the same app.

Describe the solution you'd like

An option to disable the generation of the @Component and @Autowire annotations on the ApiClient and APIs classes for springboot related librairies.

Describe alternatives you've considered

Use sed to hack into the generated classes and remove the annotations...

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 Spring-related library generation entry points and templates responsible for ApiClient and API classes. Trace how Component and Autowire annotations are emitted, then define an option that suppresses them for Spring Boot libraries and verify generated clients can be configured independently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.