SpringDoc接口分组
接口分组配置方式
当需要对接口进行归类分组时,可以修改下配置类,将OpenAPI替换为GroupedOpenApi
@Configuration
public class OpenApiConfig {
/*@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info().title("SpringShop API")
.description("Spring shop sample application")
.version("v0.0.1")
.license(new License().name("Apache 2.0").url("http://springdoc.org")))
.externalDocs(new ExternalDocumentation()
.description("SpringShop Wiki Documentation")
.url("https://springshop.wiki.github.org/docs"));
}*/
@Bean
public GroupedOpenApi siteApi() {
return GroupedOpenApi.builder()
.group("site接口")
.pathsToMatch("/hs/**")
.build();
}
@Bean
public GroupedOpenApi adminApi() {
return GroupedOpenApi.builder()
.group("admin接口")
.pathsToMatch("/hsType/**")
.build();
}
}
在配置类的GroupedOpenApi中已经指定了配置路径,properties中的指定配置可以去掉了
#springdoc.packagesToScan=cn.lixuelong.hs.api
#springdoc.pathsToMatch=/hs/**, /hsType/**