【发布时间】:2019-10-18 21:16:42
【问题描述】:
我创建了 yaml 文件(openapi 3.0.0 格式)作为我们 API 的文档。我想在应用程序运行的 URL 上显示这个(静态)swagger-ui yaml 文件。类似 http://localhost:8080/swagger-ui 的东西。在哪里显示 yaml 文件的图形表示(与 here 相同)。 Yaml文件放在项目的根文件夹中。
我在 java 11、springboot 2.1.5 上运行应用程序,使用 maven 构建。
我尝试使用
从代码中生成 swagger yaml <dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
但这并不完美(缺少默认值、描述..)
我尝试了spring static resources,但没有成功。问题是yaml文件不是html。
还有其他(可能更好)的方式,如何显示 api 文档?
【问题讨论】:
标签: java spring-boot swagger-ui