独孤求胜 6 anos atrás
commit
11dd2dc5f9
3 arquivos alterados com 22 adições e 7 exclusões
  1. 1 1
      README.md
  2. 2 2
      pom.xml
  3. 19 4
      src/main/java/io/renren/config/SwaggerConfig.java

+ 1 - 1
README.md

99
<br> <br> <br> 
99
<br> <br> <br> 
100
100
101
101
102
**Element UI主题:**
102
**效果图:**
103
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173115_d3c045ef_63154.jpeg "在这里输入图片标题")
103
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173115_d3c045ef_63154.jpeg "在这里输入图片标题")
104
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173140_79928d91_63154.jpeg "在这里输入图片标题")
104
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173140_79928d91_63154.jpeg "在这里输入图片标题")
105
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173151_12d065db_63154.jpeg "在这里输入图片标题")
105
![输入图片说明](https://gitee.com/uploads/images/2018/0505/173151_12d065db_63154.jpeg "在这里输入图片标题")

+ 2 - 2
pom.xml

36
		<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>
36
		<qiniu.version>[7.2.0, 7.2.99]</qiniu.version>
37
		<aliyun.oss.version>2.8.3</aliyun.oss.version>
37
		<aliyun.oss.version>2.8.3</aliyun.oss.version>
38
		<qcloud.cos.version>4.4</qcloud.cos.version>
38
		<qcloud.cos.version>4.4</qcloud.cos.version>
39
		<swagger.version>2.8.0</swagger.version>
39
		<swagger.version>2.7.0</swagger.version>
40
		<joda.time.version>2.9.9</joda.time.version>
40
		<joda.time.version>2.9.9</joda.time.version>
41
		<fastjson.version>1.2.45</fastjson.version>
41
		<fastjson.version>1.2.47</fastjson.version>
42
		<hutool.version>4.1.1</hutool.version>
42
		<hutool.version>4.1.1</hutool.version>
43
43
44
		<!--wagon plugin 配置-->
44
		<!--wagon plugin 配置-->

+ 19 - 4
src/main/java/io/renren/config/SwaggerConfig.java

9
import springfox.documentation.builders.PathSelectors;
9
import springfox.documentation.builders.PathSelectors;
10
import springfox.documentation.builders.RequestHandlerSelectors;
10
import springfox.documentation.builders.RequestHandlerSelectors;
11
import springfox.documentation.service.ApiInfo;
11
import springfox.documentation.service.ApiInfo;
12
import springfox.documentation.service.ApiKey;
12
import springfox.documentation.spi.DocumentationType;
13
import springfox.documentation.spi.DocumentationType;
13
import springfox.documentation.spring.web.plugins.Docket;
14
import springfox.documentation.spring.web.plugins.Docket;
14
import springfox.documentation.swagger2.annotations.EnableSwagger2;
15
import springfox.documentation.swagger2.annotations.EnableSwagger2;
15
16
17
import java.util.List;
18
19
import static com.google.common.collect.Lists.newArrayList;
20
16
@Configuration
21
@Configuration
17
@EnableSwagger2
22
@EnableSwagger2
18
public class SwaggerConfig implements WebMvcConfigurer {
23
public class SwaggerConfig implements WebMvcConfigurer {
24
        registry.addResourceHandler("/swagger/**").addResourceLocations("classpath:/static/swagger/");
29
        registry.addResourceHandler("/swagger/**").addResourceLocations("classpath:/static/swagger/");
25
    }
30
    }
26
31
32
27
    @Bean
33
    @Bean
28
    public Docket createRestApi() {
34
    public Docket createRestApi() {
29
        return new Docket(DocumentationType.SWAGGER_2)
35
        return new Docket(DocumentationType.SWAGGER_2)
30
            .apiInfo(apiInfo())
36
            .apiInfo(apiInfo())
31
            .select()
37
            .select()
32
            .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))           //加了ApiOperation注解的方法,生成接口文档
33
            //.apis(RequestHandlerSelectors.basePackage("io.renren.modules.job.controller"))  //包下的类,生成接口文档
38
            //加了ApiOperation注解的类,才生成接口文档
39
            .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
40
            //包下的类,才生成接口文档
41
            //.apis(RequestHandlerSelectors.basePackage("io.renren.controller"))
34
            .paths(PathSelectors.any())
42
            .paths(PathSelectors.any())
35
            .build();
43
            .build()
44
            .securitySchemes(security());
36
    }
45
    }
37
46
38
    private ApiInfo apiInfo() {
47
    private ApiInfo apiInfo() {
40
            .title("人人开源")
49
            .title("人人开源")
41
            .description("renren-fast文档")
50
            .description("renren-fast文档")
42
            .termsOfServiceUrl("http://www.renren.io")
51
            .termsOfServiceUrl("http://www.renren.io")
43
            .version("2.0")
52
            .version("2.1")
44
            .build();
53
            .build();
45
    }
54
    }
46
55
56
    private List<ApiKey> security() {
57
        return newArrayList(
58
            new ApiKey("token", "token", "header")
59
        );
60
    }
61
47
}
62
}