[swagger-codegen-maven-plugin] How to generate @FeignClient

1,759 views
Skip to first unread message

Gerard Bosch

unread,
Oct 21, 2018, 9:57:02 AM10/21/18
to Swagger
Hello,

I want to generate the API contract for Spring, this is, I want to generate only the interface and models for the server so I can bundle it and distributed as a Maven artifact. I was able to make it using the `<interfaceOnly>true</interfaceOnly>` option in POM plugin configuration.

But I would like to generate the `@FeignClient` interface as well and here comes the problem. If I try to configure it to use the library `spring-cloud` as I read somewhere I got the following error when I make `mvn compile`:

    io.swagger.codegen.v3:swagger-codegen-maven-plugin:3.0.2:gen‌​erate failed: Unknown library: spring-cloud
   
[ERROR] Available libraries:
   
[ERROR]   spring-boot
   
[ERROR]   spring-mvc


Here the piece of plugin configuration I am trying to use:

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

   
I added the `spring-cloud-starter-feign` to my POM as well, in `<dependencies>` section:

    <dependency>
       
<groupId>org.springframework.cloud</groupId>
       
<artifactId>spring-cloud-starter-feign</artifactId>
   
</dependency>

and the following in `<dependencyManagement>`:

    <dependencies>
       
<dependency>
           
<groupId>org.springframework.cloud</groupId>
           
<artifactId>spring-cloud-dependencies</artifactId>
           
<version>Finchley.SR1</version>
           
<type>pom</type>
           
<scope>import</scope>
       
</dependency>
   
</dependencies>



The version of swagger-codegen-maven-plugin I use is 3.0.2:

    <plugin>
       
<groupId>io.swagger.codegen.v3</groupId>
       
<artifactId>swagger-codegen-maven-plugin</artifactId>
       
<version>3.0.2</version>    
        ...



How can I make it to generate contract interface, models, and @FeignClient for Spring? Is it something missing/wrong in my POM?

Gerard Bosch

unread,
Oct 21, 2018, 11:05:14 AM10/21/18
to Swagger
I tried with this dependency as well: <artifactId>spring-cloud-starter-openfeign</artifactId>


El diumenge, 21 octubre de 2018 15:57:02 UTC+2, Gerard Bosch va escriure:

Gerard Bosch

unread,
Oct 21, 2018, 11:53:47 AM10/21/18
to Swagger
It seems that the answer to my problem is here:


spring-cloud library was (temporarily) disabled in 3.0.1.

El diumenge, 21 octubre de 2018 17:05:14 UTC+2, Gerard Bosch va escriure:
Reply all
Reply to author
Forward
0 new messages