swagger-api / swagger-api/swagger-codegen

[Java] Client generation - Duplicate variable declaration

Open
#8,080 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Generate client
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.