How to generate spring cloud feign client using swagger-codegen-maven-plugin

11.1k views Asked by At

I want to generate my feign client code using swagger-codegen, but I cannot find the docs which can lead me to do it.

I have a microservice using spring cloud, several api-services using spring-cloud-feign interfaces to request the data.I wish that i can generate the feign client code.

<plugin>
                <groupId>io.swagger</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>2.2.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>http://localhost:9141/v2/api-docs?group=building-service-api</inputSpec>
                            <language>java</language>
                            <output>${project.build.directory}/generated-sources/swagger</output>
                            <library>feign</library>
                        </configuration>
                    </execution>
                </executions>
            </plugin> 

language/library set to 'java/feign', there are only models without feign client;

language set to 'spring', 'feign' is unsupported library.

I am confused how to generate all my code? There seems to be almost no guideline or doc or demo?

1

There are 1 answers

4
Erik Möller On BEST ANSWER

Add spring-cloud-starter-feign dependency in your pom.xml and:

<configuration>
    <language>spring</language>
    <library>spring-cloud</library>
</configuration>