OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA][resttemplate] 5.0.0-beta - missing import of HttpBearerAuth in ApiClient
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
openapi-generator version
5.0.0-beta
It is a regression. 4.3.1 worked fine.
OpenAPI declaration file content or url
paths:
/foo:
get:
security:
- testAuth: []
components:
securitySchemes:
testAuth:
type: http
scheme: TEST
in: header
Command line used for generation
<generatorName>java</generatorName>
<library>resttemplate</library>
<generateApis>true</generateApis>
<generateApiDocumentation>true</generateApiDocumentation>
<generateApiTests>false</generateApiTests>
<generateModels>true</generateModels>
<generateModelDocumentation>false</generateModelDocumentation>
<generateModelTests>false</generateModelTests>
<generateSupportingFiles>true</generateSupportingFiles>
Steps to reproduce
OpenAPI declaration needs to have securitySchemes with http auth.
After openapi-generator-maven-plugin generates classes, maven-compiler-plugin fails to compile class ApiClient.
It says that symbol HttpBearerAuth is not found.
ApiClient is missing import of HttpBearerAuth. This class is in "auth" subpackage.
The compilation error is in generated ApiClient class on the following line:
authentications.put("testAuth", new HttpBearerAuth("TEST"));
Related issues/PRs
Suggest a fix
Add import to HttpBearerAuth in ApiClient if HTTP auth is used.
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 inspecting the Java RestTemplate generator templates and the generated ApiClient import section, then reproduce the Maven compilation failure with the provided OpenAPI security scheme. Done means generated ApiClient compiles when HTTP authentication creates HttpBearerAuth from the auth subpackage, while existing generation behavior remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100