1.Swagger的ben实例Docket
1.将Docke对象t加入容器中
@Bean
public Docket docket(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apinfo());
}
2.Docket源码
【1】返回docket实例需要DocumentationType的参数
public Docket(DocumentationType documentationType);
【2】DocumentationType自定义了三种默认值。选swagger2即可
public static final DocumentationType SWAGGER_12 = new DocumentationType("swagger", "1.2");
public static final DocumentationType SWAGGER_2 = new DocumentationType("swagger", "2.0");
public static final DocumentationType SPRING_WEB = new DocumentationType("spring-web", "1.0");
【3】docket.apiInfo()方法获取信息,但是docket只有get方法,即我们创建自己的apiInfo类
【4】自定义apiInfo方法,返回自定义apiInfo类,apiInfo类只有构造器和get方法,只能自定义。
private ApiInfo apinfo(){
Contact DEFAULT_CONTACT = new Contact("刘庆", "", "2073565236@qqcom");
return new ApiInfo("刘庆的swagger",
"you see you,one day day",
"1.0",
"urn:tos",
DEFAULT_CONTACT,
"Apache 2.0",
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList());
}