swagger-api / swagger-api/swagger-codegen
[Java] Client generation - Duplicate variable declaration
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I am generating a Java client. The generation is fine and no errors. However during compile I get an error as described below.
Swagger-codegen version
2.3.1
Swagger declaration file content or url
https://www.zuora.com/wp-content/themes/zuora/yaml/swagger.yaml
Command line used for generation
Using Gradle plugin.
Steps to reproduce
- Generate client
- Try to compile generated code
/zuora/api/ConnectionsApi.java:99: error: variable contentType is already defined in method pOSTConnections(String,String,String,String)
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
Suggest a fix/enhancement
Looking in the generated file is clear what the issue is. The method signature has a String contentType param.
public CommonResponseType pOSTConnections(String apiAccessKeyId, String apiSecretAccessKey, String contentType, String zuoraEntityIds)
However later in the method it is getting redeclared as a MediaType.
final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);
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 generated Java client with the linked Swagger YAML and Gradle plugin, then inspect /zuora/api/ConnectionsApi.java around pOSTConnections. Trace that output back to the Java client-generation template and verify the generated client compiles without the duplicate contentType declaration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100