You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am generating a spring web client from an external API. The api has a path parameter that is named "path", which I believe is valid in the openapi spec. I get a compilation error because the generated code tries to create a new variable called path when there is already a method argument called path.
Using java 21 and maven version >= 3.2, be in a directory with the above pom.xml
run mvn clean install
Observe compilation error:
[ERROR] src/test/java/io/swagger/client/api/DefaultApi.java:[78,16] variable path is already defined in method myobjPathGetWithHttpInfo(java.lang.String)
You might also see this which has the same root cause:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] src/test/java/io/swagger/client/api/DefaultApiTest.java:[30,19] cannot find symbol
symbol: class DefaultApi
location: class io.swagger.client.api.DefaultApiTest
Related issues/PRs
None that I know of.
Suggest a fix/enhancement
Should probably check if your variable names conflict with method parameters on generation. Might be less readable/not great, but you could just add numbers or characters after your variable name until it doesn't conflict with any method parameter names. Or just overwrite it by not redeclaring the variable.
The text was updated successfully, but these errors were encountered:
Description
I am generating a spring web client from an external API. The api has a path parameter that is named "path", which I believe is valid in the openapi spec. I get a compilation error because the generated code tries to create a new variable called
path
when there is already a method argument calledpath
.Swagger-codegen version
swagger-codegen-maven-plugin.version
is2.4.39
Swagger declaration file content or url
Command line used for generation
I am using the maven plugin.
pom.xml: https://gist.github.com/kodonnell-heila/581a7fa40ecae5dd529251bb0fbd9130
command:
mvn clean install
Steps to reproduce
pom.xml
mvn clean install
You might also see this which has the same root cause:
Related issues/PRs
None that I know of.
Suggest a fix/enhancement
Should probably check if your variable names conflict with method parameters on generation. Might be less readable/not great, but you could just add numbers or characters after your variable name until it doesn't conflict with any method parameter names. Or just overwrite it by not redeclaring the variable.
The text was updated successfully, but these errors were encountered: