SwaggerConfig.java
1.75 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
package com.diligrp.swaggerConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* com.wlqq.pk.server.swagger
* 16/1/13
*
* @author weiming.liao
*/
@Configuration
@EnableWebMvc
@EnableSwagger2
//@ComponentScan(basePackages = {"com.b2c.myapp.api"})
public class SwaggerConfig extends WebMvcConfigurerAdapter {
public static final String SWAGGER_SCAN_BASE_PACKAGE = "com.diligrp.mobsite.getway.web.api";
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
@Bean
public Docket swaggerSpringMvcPlugin(){
Docket docket = new Docket(DocumentationType.SWAGGER_2);
docket.select().apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)).build();
ApiInfo apiInfo = new ApiInfo("咱的APP", "移动网关接口", "1.1", "urn:tos", "b2c", "account-park", "http://zandeapp.com");
docket.apiInfo(apiInfo);
return docket;
}
}