我需要使用 swagger-codegen-plugin (for maven) 在 eclipse 中生成服务器存根代码。你能帮忙怎么做吗?以及需要什么配置(在 pom.xml 中)。
原文由 rajesh reddy SR 发布,翻译遵循 CC BY-SA 4.0 许可协议
我需要使用 swagger-codegen-plugin (for maven) 在 eclipse 中生成服务器存根代码。你能帮忙怎么做吗?以及需要什么配置(在 pom.xml 中)。
原文由 rajesh reddy SR 发布,翻译遵循 CC BY-SA 4.0 许可协议
<!-- Swagger -->
<plugin>
<groupId>io.swagger</groupId>
<artifactId>swagger-codegen-maven-plugin</artifactId>
<version>2.3.1</version>
<executions>
<execution>
<id>contract-service</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${basedir}/src/main/resources/swagger/rest-data-exchange-format.yaml</inputSpec>
<artifactId>contract-service</artifactId>
<output>${basedir}/target/generated-sources</output>
<language>spring</language>
<modelPackage>ru.payhub.rest.v1.model</modelPackage>
<apiPackage>ru.payhub.rest.v1.api</apiPackage>
<!-- <invokerPackage>ru.payhub.rest.v1.handler</invokerPackage> -->
<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
<sourceFolder>src/main/java</sourceFolder>
<interfaceOnly>true</interfaceOnly>
<library>spring-boot</library>
<dateLibrary>${generator.datelibrary}</dateLibrary>
<configPackage>ru.payhub.config</configPackage>
<singleContentTypes>true</singleContentTypes>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
官方参数说明 在这里
Swagger 语法规范 在这里
在这个示例 maven 插件中,使用 swagger 数据模型文件 (yaml) 生成模型类以在控制器中使用它。
原文由 Mikro Koder 发布,翻译遵循 CC BY-SA 4.0 许可协议
15 回答8.4k 阅读
8 回答6.2k 阅读
1 回答4k 阅读✓ 已解决
3 回答6k 阅读
2 回答2.2k 阅读✓ 已解决
3 回答2.2k 阅读✓ 已解决
2 回答3.1k 阅读
我找到了这个答案。您只需要像下面这样更改 pom.xml。
pom.xml。