OpenAPITools / OpenAPITools/openapi-generator
[BUG] Java clients generated via inputSpecRootDirectory ignore securitySchemas in YAML
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? Here: https://github.com/wilx/inputSpecRootDirectory-issue
- Have you validated the input using an OpenAPI validator (example)? — It is trivial and I can't access the site from here.
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs? — Yes and I did not find anything relevant.
- What's the actual output vs expected output? — See the reproducer project at and its README.md
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
See the diff in the reproducer project at https://github.com/wilx/inputSpecRootDirectory-issue#. The issue manifests as missing authentication schemas in the ApiClient.java when the Maven plugin is using inputSpecRootDirectory. The difference is this:
--- ./using-inputSpec/target/generated-sources/openapi/src/main/java/com/example/ApiClient.java 2025-04-23 11:07:03.367877854 +0200
+++ ./using-inputSpecRootDirectory/target/generated-sources/openapi/src/main/java/com/example/ApiClient.java 2025-04-23 11:07:04.889861008 +0200
@@ -1,6 +1,6 @@
/*
- * Minimal Bearer Auth API
- * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
+ * merged spec
+ * merged spec
*
* The version of the OpenAPI document: 1.0.0
*
@@ -58,16 +58,7 @@ public class ApiClient {
public ApiClient(String[] authNames) {
this();
for(String authName : authNames) {
- Interceptor auth = null;
- if ("bearerAuth".equals(authName)) {
-
- auth = new HttpBearerAuth("bearer");
- } else {
- throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
- }
- if (auth != null) {
- addAuthorization(authName, auth);
- }
+ throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
}
@@ -103,7 +94,7 @@ public class ApiClient {
public void createDefaultAdapter() {
json = new JSON();
- String baseUrl = "https://api.example.com/v1";
+ String baseUrl = "http://localhost:8080";
if (!baseUrl.endsWith("/"))
baseUrl = baseUrl + "/";
openapi-generator version
7.12.0
OpenAPI declaration file content or url
The same file that is in the reproducer project. The issue is not the YAML itself.
openapi: 3.0.3
info:
title: Minimal Bearer Auth API
version: 1.0.0
servers:
- url: https://api.example.com/v1
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
security:
- bearerAuth: []
paths:
/user/profile:
get:
summary: Get user profile
description: Retrieve profile information for the authenticated user.
responses:
'204':
description: Successful response
Generation Details
Just run mvn clean install in the reproducer project root.
Steps to reproduce
See above. The difference is in the inputSpecRootDirectory vs inputSpec.
Related issues/PRs
🙅🏿
Suggest a fix
🤷♂
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 running mvn clean install in the linked reproducer project and compare generation through inputSpec with inputSpecRootDirectory. Read the Maven plugin configuration and the generated ApiClient.java; done means the latter includes the bearerAuth security handling and matches the expected output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100