OpenAPITools / OpenAPITools/openapi-generator
[BUG] Error in Vertx with header with "-"
Open
Nobody has claimed this yet.
Issue: Bug
- 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)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
code generate with error
private final Map<String, Authentication> authentications = new LinkedHashMap<>();
public void addX-Auth-TokenAuthentication(String apikey, String apiKeyPrefix) {
ApiKeyAuth auth = new ApiKeyAuth("header","X-Auth-Token");
auth.setApiKey(apikey);
auth.setApiKeyPrefix(apiKeyPrefix);
authentications.put("X-Auth-Token", auth);
}
public static AuthInfo forX-Auth-TokenAuthentication(String apikey, String apiKeyPrefix) {
AuthInfo authInfo = new AuthInfo();
authInfo.addX-Auth-TokenAuthentication(apikey, apiKeyPrefix);
return authInfo;
}
}
openapi-generator version
7.0.1
OpenAPI declaration file content or url
"swagger": "2.0",
....
"securityDefinitions": {
"X-Auth-Token": {
"description": "",
"type": "apiKey",
"name": "X-Auth-Token",
"in": "header"
}
},
....
Generation Details
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger.json</inputSpec>
<generatorName>java</generatorName>
<cleanupOutput>true</cleanupOutput>
<generateSupportingFiles>true</generateSupportingFiles>
<modelNamePrefix>pre</modelNamePrefix>
<generateApiTests>false</generateApiTests>
<generateModelTests>false</generateModelTests>
<generateApiDocumentation>true</generateApiDocumentation>
<configOptions>
<library>vertx</library>
<dateLibrary>java8-localdatetime</dateLibrary>
</configOptions>
</configuration>
</execution>
</executions>```
##### Steps to reproduce
to have an authorization header with "-"
##### Related issues/PRs
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
Reproduce the generation with the supplied Swagger 2.0 security definition, generatorName=java, and library=vertx, then trace how AuthInfo authentication method names are produced. Done means the X-Auth-Token header no longer creates invalid Java method names and the generated client remains compilable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100