swagger 配置类
程序员文章站
2024-03-20 20:35:40
...
swagger 配置类
@Configuration
@EnableSwagger2
@Profile({"dev", "debug"})
public class SwaggerConfig {
@Bean
public Docket adminApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(SystemConstant.BACKGROUND_BUSINESS_INTERFACE)
.apiInfo(apiInfo(SystemConstant.BACKGROUND_BUSINESS_INTERFACE, "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.r*z.o2o"))
// .apis(RequestHandlerSelectors.basePackage("com.vito"))
// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(PathSelectors.regex("/admin.*"))
.build().protocols(Stream.of("http").collect(Collectors.toSet()));
}
@Bean
public Docket adminFrameworkApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(SystemConstant.BACKGROUND_FRAME_INTERFACE)
.apiInfo(apiInfo(SystemConstant.BACKGROUND_FRAME_INTERFACE, "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.vito.framework"))
// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(PathSelectors.regex("/admin.*"))
.build().protocols(Stream.of("http").collect(Collectors.toSet()));
}
@Bean
public Docket deliveryApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(SystemConstant.DELIVERY_API_INTERFACE)
.apiInfo(apiInfo(SystemConstant.DELIVERY_API_INTERFACE, "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.r*z.h****e.api.delivery"))
// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(PathSelectors.regex("/api.*"))
.build().protocols(Stream.of("http").collect(Collectors.toSet()));
}
@Bean
public Docket restApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(SystemConstant.API_INTERFACE)
.apiInfo(apiInfo(SystemConstant.API_INTERFACE, "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.r*z.h****e.api.customer"))
// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(PathSelectors.regex("/api.*"))
.build().protocols(Stream.of("http").collect(Collectors.toSet()));
}
@Bean
public Docket shopApi() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(SystemConstant.SHOP_API_INTERFACE)
.apiInfo(apiInfo(SystemConstant.SHOP_API_INTERFACE, "1.0"))
.useDefaultResponseMessages(true)
.forCodeGeneration(false)
.select()
.apis(RequestHandlerSelectors.basePackage("com.r*z.h****e.api.shop"))
// .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(PathSelectors.regex("/api.*"))
.build().protocols(Stream.of("http").collect(Collectors.toSet()));
}
/**
* 访问地址:http://ip:port/swagger-ui.html
*
* @return
*/
private ApiInfo apiInfo(String title, String version) {
return new ApiInfoBuilder()
.title(title)
.version(version)
.build();
}
}
上一篇: Js/Jquery获取input file的文件名
下一篇: 文件上传显示保存到数据库实现类