swagger-api / swagger-api/swagger-codegen

Two similar parameters/attributes are generated with the same name (clashing names)

Open
#10,900 0 comments 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

The generator is creating clashing local variable names when two different parameters cause a naming clash (i.e., company_name and companyName both generate companyName whereas are different from the API perspective).

Swagger-codegen version

3.0.24

Swagger declaration file content or url

https://interactivebrokers.github.io/cpwebapi/swagger.json

Attached is the json converted to yaml (v3).
ib.zip

Command line used for generation

Using maven generator with the following:

<plugin>
                <groupId>io.swagger.codegen.v3</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>3.0.24</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${project.basedir}/src/main/resources/ib.yaml</inputSpec>
                            <language>java</language>
                            <modelPackage>test.model</modelPackage>
                            <apiPackage>test.api</apiPackage>
                            <invokerPackage>test.api</invokerPackage>
                            <checkDuplicatedModelName>true</checkDuplicatedModelName>
                            <configOptions>
                                <library>feign</library>
                                <serializableModel>true</serializableModel>
                                <dateLibrary>java8</dateLibrary>
                                <java8>true</java8>  
                                <ensureUniqueParams>true</ensureUniqueParams>                              
                                <checkDuplicatedModelName>true</checkDuplicatedModelName>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
Steps to reproduce

Just download the URL and run the CLI or maven plugin. See the file Contract (test.Contract).

Related issues/PRs
Suggest a fix/enhancement

I don't know the project enough to suggest much, but perhaps a quick check of attributes can be done and rename those that already exist before generation.

Note: I know I could change the code after generation, but that means commenting out the section in pom.xml once is generated, and if there is a mistake, then the nightmare starts.

Thanks!

Juan

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 clash using the attached ib.yaml through the CLI or Maven plugin, then inspect the generated test.Contract output and the Java generator's parameter-naming path. Done means company_name and companyName produce distinct local names and the generated Contract compiles without manual edits.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.