Swagger

配置依赖

配置依赖

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.1.0</version>
</dependency>

在方法上加上注解(不加也会生成接口文档):

java
@Operation(summary = "添加单条新闻")
@PostMapping("/")
public NewsDto createNews(@Valid @RequestBody News news) {
    ...
}

进入后台查看接口

http://localhost:1688/swagger-ui/index.html

image-20250405212410786

评论

评论加载中……