package com.example.swagger.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
//配置了swagger的Docket实例
@Bean
public Docket docket(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//配置一扫描接口的方式
.apis(RequestHandlerSelectors.basePackage("com.example.swagger.controller"))
//过滤什么路径
.paths(PathSelectors.ant("/example/**"))
.build()
;
}
private ApiInfo apiInfo(){
//作者信息
Contact contact = new Contact("cj", "https://www.baidu.com/?tn=62095104_33_oem_dg", "");
return new ApiInfo(
"CJ YYDS",
"CJ YYDS",
"1.0",
"urn:tos",
contact,
"Apache 2.0",
"https://www.baidu.com/?tn=62095104_33_oem_dg",
new ArrayList()
);
}
}
Swagger2.0 配置
最新推荐文章于 2023-09-21 17:48:40 发布