OSSSwaggerConfig.java
2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.brframework.commonoss.config;
import com.brframework.commonweb.core.SwaggerContext;
import com.google.common.collect.Lists;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.service.Parameter;
import springfox.documentation.spring.web.plugins.Docket;
import java.util.List;
/**
* @Author xu
* @Date 2018/1/3 0003 下午 3:30
* Swagger api生成
*/
@Configuration
@Data
public class OSSSwaggerConfig {
@Value("${swagger.enable}")
private boolean enable;
private String groupName = "oss";
private String packageName = "com.brframework.commonoss.web";
private String title = "对象存储";
private String description = "对象存储";
private String termsOfServiceUrl = "";
private String version = "1.0";
private String contactName = "beiru";
private String contactUrl = "https://www.software-br.com";
private String contactEmail = "";
@Bean("ossDocket")
public Docket api() {
List<Parameter> list = Lists.newArrayList();
return SwaggerContext.createDocket(groupName, packageName, apiInfo(), list, enable);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(title)//大标题
.description(description)//详细描述
.version(version)//版本
.termsOfServiceUrl(termsOfServiceUrl)
.contact(new Contact(contactName, contactUrl, contactEmail))//作者
.license("The Apache License, Version 2.0")
.licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
.build();
}
}