44 lines
1.5 KiB
Java
44 lines
1.5 KiB
Java
|
|
package business.cooperop.base.config;
|
||
|
|
|
||
|
|
import org.springframework.context.annotation.Bean;
|
||
|
|
import org.springframework.context.annotation.Configuration;
|
||
|
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||
|
|
import springfox.documentation.builders.PathSelectors;
|
||
|
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||
|
|
import springfox.documentation.service.ApiInfo;
|
||
|
|
import springfox.documentation.service.Contact;
|
||
|
|
import springfox.documentation.spi.DocumentationType;
|
||
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* swagger配置类
|
||
|
|
* @Author: deadline
|
||
|
|
* @Date: 2021-01-04 20:55
|
||
|
|
*/
|
||
|
|
@Configuration
|
||
|
|
public class SwaggerConfig {
|
||
|
|
Boolean swaggerEnabled = true;
|
||
|
|
|
||
|
|
@Bean
|
||
|
|
public Docket createRestApi() {
|
||
|
|
return new Docket(DocumentationType.OAS_30).apiInfo(apiInfo())
|
||
|
|
// 是否开启
|
||
|
|
.enable(swaggerEnabled).select()
|
||
|
|
// 扫描的路径包
|
||
|
|
.apis(RequestHandlerSelectors.basePackage("business.cooperop.base"))
|
||
|
|
// 指定路径处理PathSelectors.any()代表所有的路径
|
||
|
|
.paths(PathSelectors.any()).build().pathMapping("/");
|
||
|
|
}
|
||
|
|
|
||
|
|
private ApiInfo apiInfo() {
|
||
|
|
return new ApiInfoBuilder()
|
||
|
|
.title("连锁ERP管理端API")
|
||
|
|
.description("springboot | swagger")
|
||
|
|
// 作者信息
|
||
|
|
.contact(new Contact("成都超然祥润科技有电公司", "chaoran.crtech.cn:8848/nacos", "crtech.163.com"))
|
||
|
|
.version("1.0.0")
|
||
|
|
.build();
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|