swagger-api / swagger-api/swagger-codegen
[JAVA] Bug generating a client with openfeign
Nobody has claimed this yet.
- #10319 by @tseale07 — closed without merging
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When attempting to generate a java client with open feign, the following error occurs when attempting to compile the code:
[exec] [INFO] -------------------------------------------------------------
[exec] [ERROR] COMPILATION ERROR :
[exec] [INFO] -------------------------------------------------------------
[exec] [ERROR] /Users/tseale/Documents/code/work/dapi-configuration/target/generated-sources/swagger/java/src/main/java/io/swagger/api/DefaultApiClient.java:[3,47] package org.springframework.cloud.openfeign does not exist
[exec] [ERROR] /Users/tseale/Documents/code/work/dapi-configuration/target/generated-sources/swagger/java/src/main/java/io/swagger/api/DefaultApiClient.java:[6,2] cannot find symbol
[exec] symbol: class FeignClient
[exec] [INFO] 2 errors
Swagger-codegen version
3.0.20, 2.4.14
Pom configuration used for generation
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>${swagger-codegen-maven-plugin.version}</version>
<executions>
<execution>
<id>generate-swagger-client-java</id>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.build.directory}/swagger.json</inputSpec>
<output>${swagger.codegen.output.dir.java}</output>
<language>spring</language>
<library>spring-cloud</library>
<configOptions>
<generateForOpenFeign>true</generateForOpenFeign>
<groupId>${project.parent.groupId}</groupId>
<artifactId>${project.name}-java-client</artifactId>
<artifactVersion>${project.version}</artifactVersion>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
Steps to reproduce
- Set the version to 2.4.14
- Set the
languagetospringand thelibrarytospring-cloud - Set the
generateForOpenFeignoption totrue - auto generate the client with the above configurations
- run the command
mvn clean installin the auto generated project
Related issues/PRs
This is related to the support of openfeign in the 2.4.14 release: https://github.com/swagger-api/swagger-codegen/pull/9120
Suggest a fix/enhancement
the pom.mustache needs to include the dependency for openfeign instead of netflix.feign based on the generateForOpenFeign option.
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
Start by locating the generator's pom.mustache template and inspect how the generateForOpenFeign option selects dependencies. Reproduce the issue by generating the Java client with the listed Maven settings and running mvn clean install. Done means the generated project includes the OpenFeign dependency and compiles successfully; review PR 10319 for prior work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100