swagger-api / swagger-api/swagger-codegen

[JAVA] Bug generating a client with openfeign

Open
#10,318 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Set the version to 2.4.14
  2. Set the language to spring and the library to spring-cloud
  3. Set the generateForOpenFeign option to true
  4. auto generate the client with the above configurations
  5. run the command mvn clean install in 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

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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.