如何使用swagger-codegen-maven-plugin生成spring cloud feign客户端 [英] How to generate spring cloud feign client using swagger-codegen-maven-plugin

查看:48
本文介绍了如何使用swagger-codegen-maven-plugin生成spring cloud feign客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 swagger-codegen 生成我的假客户端代码,但我找不到可以引导我这样做的文档.

我有一个使用 spring cloud 的微服务,几个使用 spring-cloud-feign 接口请求数据的 api-service.我希望我可以生成 feign 客户端代码.

<groupId>io.swagger</groupId><artifactId>swagger-codegen-maven-plugin</artifactId><version>2.2.3</version><执行><执行><目标><目标>生成</目标></目标><配置><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></配置></执行></执行></插件>

语言/库设置为'java/feign',只有没有feign客户端的模型;

语言设置为spring",feign"是不受支持的库.

我很困惑如何生成我的所有代码?似乎几乎没有指南或文档或演示?

解决方案

在你的 pom.xml 中添加 spring-cloud-starter-feign 依赖:

<预><代码><配置><语言>春天</语言><library>spring-cloud</library></配置>

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?

解决方案

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

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

这篇关于如何使用swagger-codegen-maven-plugin生成spring cloud feign客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆