springdoc-openapi:帮助spring-boot自动生成API的开源库工具


springdoc-openapi Java 库帮助你的Spring Boot项目自动生成API文档。
springdoc-openapi 通过在运行时检查应用程序来根据 Spring 配置、类结构和各种注释推断 API 语义。
该库自动生成 JSON/YAML 和 HTML 格式页面的文档。生成的文档可以使用swagger-api注释进行补充。
该库支持:

  • OpenAPI 3
  • Spring-boot (v1 and v2)
  • JSR-303, specifically for @NotNull, @Min, @Max, and @Size.
  • Swagger-ui
  • Oauth 2

特点:
  • 自动将 swagger-ui 部署到 Spring Boot 2.x 应用程序
  • 文档将以 HTML 格式提供,使用官方swagger-ui jars
  • Swagger UI 页面应在http://server:port/context-path/swagger-ui.html可用,OpenAPI 描述将在以下 json 格式的 url 可用:http://server:port/context -path/v3/api-docs
    • server:服务器名称或IP
    • port: 服务器端口
    • context-path:应用程序的上下文路径
  • 文档也可以以 yaml 格式提供,位于以下路径:/v3/api-docs.yaml
  • 将springdoc-openapi-ui库添加到项目依赖项列表中(无需额外配置):

   <dependency>
      <groupId>org.springdoc</groupId>
      <artifactId>springdoc-openapi-ui</artifactId>
      <version>last-release-version</version>
   </dependency>

点击标题