SpringBoot整合springdoc-openapi,自动生成在线接口文档。
1、引入pom依赖
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.3.0</version> </dependency>
2、webconfig里添加排除校验
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new AuthInterceptor()).excludePathPatterns(getExclude());
}
public String[] getExclude() { return new String[]{ "/v3/api-docs", "/v3/api-docs/**", "/swagger-ui.html", "/swagger-ui/**"}; }
3、配置文件里加配置
springdoc: api-docs: path: /v3/api-docs swagger-ui: path: /swagger-ui.html
4、输入url测试
http://localhost:8080/test/v3/api-docs
标签:SpringBoot,docs,v3,OpenAPI,api,ui,springdoc,文档,swagger From: https://www.cnblogs.com/shamo89/p/18153419