在我的 Spring Boot 应用程序中使用了 springfox 依赖项来显示 swagger ui。使用注释,如
@SwaggerDefinition
和 @EnableSwagger2
。
但是它们不会生成任何 html 或 json/yaml 或任何客户端代码。 所以我使用了在以下位置找到的插件:https://github.com/kongchen/swagger-maven-example
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
......
</plugin>
但他们也没有帮助,我猜他们正在扫描整个包中的所有 @Api 类以生成 json,但我没有。
请问有什么建议吗?
这对我有用 kongchen 插件
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<version>3.1.7</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiSources>
<apiSource>
<info>
<title>Swagger API Specification for Your Project</title>
<version>v0.28</version>
<description>Swagger API Specification for Your Project</description>
</info>
<locations>
<location>com.yourpackage.api</location>
<location>com.yourpackage.api.controllers</location>
</locations>
<springmvc>true</springmvc>
<outputFormats>json,yaml</outputFormats>
<swaggerDirectory>
${project.build.directory}/generated/swagger-api-spec
</swaggerDirectory>
</apiSource>
</apiSources>
</configuration>
</plugin>