Swagger配置檔案
這裡配置兩個分組admin【背景管理接口】、wechat【微信管理接口】
@Configuration
@EnableSwagger2
public class Swagger2 {
public static final String SWAGGER_SCAN_ADMIN_PACKAGE = "com.jacksony.module.admin.controller";
public static final String ADMIN_VERSION = "1.0.0";
public static final String SWAGGER_SCAN_WX_PACKAGE = "com.jacksony.module.wechat.controller";
public static final String WX_VERSION = "1.0.0";
@Bean
public Docket createAdminRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("背景管理接口")
.apiInfo(apiAdminInfo())
.select()
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_ADMIN_PACKAGE))//api接口包掃描路徑
.paths(PathSelectors.regex(".*/admin/.*"))//可以根據url路徑設定哪些請求加入文檔,忽略哪些請求
.build();
}
private ApiInfo apiAdminInfo() {
return new ApiInfoBuilder()
.title("背景管理接口")//設定文檔的标題
.description("背景資料管理")//設定文檔的描述->1.Overview
.version(ADMIN_VERSION)//設定文檔的版本資訊-> 1.1 Version information
.build();
}
@Bean
public Docket createWxRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("微信管理接口")
.apiInfo(apiWxInfo())
.select()
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_WX_PACKAGE))//api接口包掃描路徑
.paths(PathSelectors.regex(".*/weixin/.*"))//可以根據url路徑設定哪些請求加入文檔,忽略哪些請求
.build();
}
private ApiInfo apiWxInfo() {
return new ApiInfoBuilder()
.title("微信管理接口")//設定文檔的标題
.description("微信開發接口實作的文檔")//設定文檔的描述->1.Overview
.version(WX_VERSION)//設定文檔的版本資訊-> 1.1 Version information
.build();
}
}