Skip to content

springboot3.x 接入 openapi

官网: https://springdoc.org/

导入maven

shell
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-api</artifactId>
    <version>2.3.0</version>
</dependency>

示例代码

java

@Tag(name = "测试控制器")
@RestController
@RequestMapping("/api")
public class TestController {

    @GetMapping("/test")
    @Operation(summary = "summary测试", description = "description测试")
    public String test() {

        return LocalDateTime.now().toString();
    }
}