OpenAPITools / OpenAPITools/openapi-generator

[BUG] Description

Open
#14,106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Hello,

I don't understand why the open api generator generate two kind / approach and of constructor for ApiClient object : one with full autowirred and a second one constructor with no parameter, not annotated with @Autowired

Without having a bean providing a RestTemplate it lead to an "no bean error" at startup of the embedding application and no way to instantiate manually the API classes and ApiClient classes.

The following configuration was used for the generator in Gradle :

openApiGenerate {
generatorName = "java"
library = "resttemplate"
inputSpec = "${rootDir}/XXXX.yaml".toString()

outputDir = "${rootDir}/gensrc".toString()
/*systemProperties = [
        modelDocs      : "false",
        models         : "",
        apis           : "",
        supportingFiles: "false"
]*/

configOptions = [
        useOptional          : "true",
        swaggerDocketConfig  : "false",
        performBeanValidation: "false",
        useBeanValidation    : "false",
        useTags              : "true",
        singleContentTypes   : "true",
        basePackage          : "XXX",
        configPackage        : "XXXX.config",
        title                : rootProject.name,
        java8                : "false",
        dateLibrary          : "java8",
        serializableModel    : "true",
        artifactId           : rootProject.name,
        apiPackage           : "XXXX.api",
        modelPackage         : "XXXX.api.model",
        invokerPackage       : "XXXX.client",
        interfaceOnly        : "false",
        supportingFiles		 : 	"true",
        schema				 : "Bearer"
       
]

}

Regards

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

Reproduce the generated Java client with the Gradle openApiGenerate configuration shown, focusing on the generated ApiClient constructors and RestTemplate dependency. Trace the Java resttemplate generation entry point and compare the constructor behavior; done means the generated client can be used without the reported startup bean error and supports the intended instantiation path.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi, spring
Domain
api, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.