[BUG] [Java] [resttemplate] Spring's @Component
annotation is imported even if generateClientAsBean
is set to false
#20657
Labels
@Component
annotation is imported even if generateClientAsBean
is set to false
#20657
Bug Report Checklist
Description
The files generated from
resttemplate
are importingorg.springframework.stereotype.Component
even whengenerateClientAsBean
property is set tofalse
(default).openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache
Line 22 in dd67423
openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache
Line 31 in dd67423
According to the docs, the
@Component
annotation will be only added ifgenerateClientAsBean
is set totrue
So, to fix the issue, you just need to replace the current content with bellow suggestion in both places:
openapi-generator version
I'm currently using below settings - however I can reproduce the issue in prior versions
OpenAPI declaration file content or url
I have used your
petstore
spec to reproduce the issueSteps to reproduce
Run below command to generate the code
Go to the source files for
ApiClient
andUserApi
, you'll seeorg.springframework.stereotype.Component
being added by defaultSuggest a fix
You just need to replace the current content in:
openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/api.mustache
Line 22 in dd67423
openapi-generator/modules/openapi-generator/src/main/resources/Java/libraries/resttemplate/ApiClient.mustache
Line 31 in dd67423
with below code
The text was updated successfully, but these errors were encountered: