其实用的是springdoc-openapi
只要加入依赖
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.0.2</version>
</dependency>
1674558071277.png
为了一个在线文档用了这么多依赖,不太划算,生产环境关了吧
配置 不是必须的也可以不写 只要加入依赖就可以了
package com.gzz.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
@Configuration
public class OpenApiConfig {
@Bean
public OpenAPI springOpenAPI() {
return new OpenAPI().info(new Info() //
.title("SpringDoc API Test") //
.description("SpringDoc Simple Application Test") //
.version("0.0.1"));
}
}
就完事儿了,其它的就跟你用过的swagger一样儿了
http://localhost:8080/swagger-ui/index.html
从SpringFox迁移
SpringFox | SpringDoc |
---|---|
@Api | @Tag |
@ApiIgnore | @Parameter(hidden = true)or@Operation(hidden = true)or@Hidden |
@ApiImplicitParam | @Parameter |
@ApiImplicitParams | @Parameters |
@ApiModel | @Schema |
@ApiModelProperty | @Schema |
@ApiOperation(value = "foo", notes = "bar") | @Operation(summary = "foo", description = "bar") |
@ApiParam | @Parameter |
@ApiResponse(code = 404, message = "foo") | ApiResponse(responseCode = "404", description = "foo") |
网友评论