基于 SpringDoc 的 OpenAPI 3.0 文档自动生成,提供 Swagger UI 界面。

仓库坐标

Servlet 环境

Maven

<dependency>
    <groupId>com.luamas.thinkbridge</groupId>
    <artifactId>openapi-ui-spring-boot-starter</artifactId>
</dependency>

Gradle

implementation("com.luamas.thinkbridge:openapi-ui-spring-boot-starter")

WebFlux 环境

[[OpenAPI WebFlux UI]]

Maven

<dependency>
    <groupId>com.luamas.thinkbridge</groupId>
    <artifactId>openapi-webflux-ui-spring-boot-starter</artifactId>
</dependency>

Gradle

implementation("com.luamas.thinkbridge:openapi-webflux-ui-spring-boot-starter")

WebFlux 环境说明

此模块是 openapi-ui-spring-boot-starter 的 WebFlux 版本,自动配置方式相同,但适配 Reactive 环境。

WebFlux 环境下必须使用 openapi-webflux-ui-spring-boot-starter,而非 openapi-ui-spring-boot-starter。

配置

think:
  openapi:
    # 是否启用,默认 true
    enabled: true
    # API文档标题
    title: API Docs
    # API文档描述
    description: Application API Documentation
    # API版本
    version: 1.0.0
    # 联系人信息
    contact-name: Developer
    contact-email: dev@example.com
    contact-url: https://example.com

配置属性一览

属性

默认值

说明

think.openapi.enabled

true

是否启用OpenAPI文档

think.openapi.title

API Docs

文档标题

think.openapi.description

文档描述

think.openapi.version

1.0.0

API版本

think.openapi.contact-name

联系人姓名

think.openapi.contact-email

联系人邮箱

think.openapi.contact-url

联系人URL

示例配置

# thinkbridge 定制化配置
think:
  openapi:
    global-operation-parameters:
      - { name: username, default-value: test, model-ref: string, parameter-type: header }
      - { name: password, model-ref: string, parameter-type: header }
    info:
      title: ThinkBridge
      description: ThinkBridge Doc
# springdoc 配置
springdoc:
    show-actuator: false
    api-docs:
      enabled: true
      # api地址
      path: /v3/api-docs
    swagger-ui:
      # 访问地址
      path: /swagger
      displayRequestDuration: true
      tagsSorter: alpha
    packages-to-scan: com.luamas
    paths-to-exclude: /error
生产环境建议设置 think.openapi.enabled=false 关闭文档。