groupName()
方法 设置分组
可以通过设置分组,将api按apis()
,paths()
分开,给不同的前端开发人员使用。
设置多个分组,意味着,需要多种配置方案,而一个Docket,对应一种配置方案,这个时候就需要多个Docket实例去实现分组。
代码如下:
@Bean
public Docket docket1(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("group1")
.enable(true)
.select()
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket docket2(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("group2")
.enable(true)
.select()
.paths(PathSelectors.any())
.build();
}
@Bean
public Docket docket3(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.groupName("group3")
.enable(true)
.select()
.paths(PathSelectors.any())
.build();
}