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
package com.tanpu.fund.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import static com.google.common.collect.Lists.newArrayList;
import static com.google.common.collect.Sets.newHashSet;
@Profile("dev")
@Configuration
@EnableSwagger2
public class Swagger2Config {
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("探普云-产品")
.version("1.0.0")
.build();
}
@Bean
public Docket customImplementation(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.tanpu.product"))
.build()
.protocols(newHashSet("http", "https"))
// .protocols(newHashSet("ws", "wss"))
.securitySchemes(newArrayList(basicAuth()))
.apiInfo(apiInfo())
.forCodeGeneration(true);
}
private ApiKey basicAuth() {
ApiKey apiKey = new ApiKey(JWT_AUTH_FLAG, JWT_AUTH_FLAG, "header");
return apiKey;
}
public static final String JWT_AUTH_FLAG = "jwt";
}