SwaggerConfig.java 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package com.yihu.jw.config.mvc;
  2. import com.yihu.jw.commnon.base.base.BaseContants;
  3. import com.yihu.jw.commnon.base.wx.WechatContants;
  4. import com.yihu.jw.commnon.wlyy.AgreementContants;
  5. import org.springframework.context.annotation.Bean;
  6. import org.springframework.context.annotation.ComponentScan;
  7. import org.springframework.context.annotation.Configuration;
  8. import springfox.documentation.service.ApiInfo;
  9. import springfox.documentation.spi.DocumentationType;
  10. import springfox.documentation.spring.web.plugins.Docket;
  11. import springfox.documentation.swagger2.annotations.EnableSwagger2;
  12. import static com.google.common.base.Predicates.or;
  13. import static springfox.documentation.builders.PathSelectors.regex;
  14. @Configuration
  15. @EnableSwagger2
  16. @ComponentScan("com.yihu.jw.**")
  17. public class SwaggerConfig {
  18. public static final String gateway_API = "gateway";
  19. @Bean
  20. public Docket gatewayAPI() {
  21. return new Docket(DocumentationType.SWAGGER_2)
  22. .groupName(gateway_API)
  23. .useDefaultResponseMessages(false)
  24. .forCodeGeneration(false)
  25. .pathMapping("/")
  26. .select()
  27. .paths(or(
  28. regex("/" + AgreementContants.wlyy + "/.*")
  29. , regex("/" + WechatContants.api_common + "/.*")
  30. , regex("/" + BaseContants.api_common + "/.*")
  31. ))
  32. .build()
  33. .apiInfo(gatewayApiInfo());
  34. }
  35. private ApiInfo gatewayApiInfo() {
  36. ApiInfo apiInfo = new ApiInfo("基卫2.0API",
  37. "基卫2.0API,提供基础卫生相关服务。",
  38. "1.0",
  39. "No terms of service",
  40. "wenfujian@jkzl.com",
  41. "The Apache License, Version 2.0",
  42. "http://www.apache.org/licenses/LICENSE-2.0.html"
  43. );
  44. return apiInfo;
  45. }
  46. }