SwaggerConfig.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package com.yihu.wlyy.config;
  2. import org.springframework.context.annotation.Bean;
  3. import org.springframework.context.annotation.ComponentScan;
  4. import org.springframework.context.annotation.Configuration;
  5. import org.springframework.web.context.request.async.DeferredResult;
  6. import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  7. import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
  8. import springfox.documentation.builders.ApiInfoBuilder;
  9. import springfox.documentation.builders.PathSelectors;
  10. import springfox.documentation.service.ApiInfo;
  11. import springfox.documentation.service.Contact;
  12. import springfox.documentation.spi.DocumentationType;
  13. import springfox.documentation.spring.web.plugins.Docket;
  14. import springfox.documentation.swagger2.annotations.EnableSwagger2;
  15. @Configuration
  16. @EnableWebMvc
  17. @EnableSwagger2
  18. @ComponentScan("com.yihu.wlyy.controller")
  19. public class SwaggerConfig extends WebMvcConfigurerAdapter {
  20. @Bean
  21. public Docket patientApi(){
  22. return new Docket(DocumentationType.SWAGGER_2)
  23. .groupName("Wlyy-manager")
  24. .genericModelSubstitutes(DeferredResult.class)
  25. .useDefaultResponseMessages(false)
  26. .forCodeGeneration(true)
  27. .pathMapping("/")
  28. .select()
  29. .paths(PathSelectors.regex("/customer/.*"))
  30. .build()
  31. .apiInfo(patientApiInfo());
  32. }
  33. private ApiInfo patientApiInfo() {
  34. return new ApiInfoBuilder()
  35. .title("三师后台管理 RESTful APIs")
  36. .description("三师后台管理 Rest API, all the applications could access the Object model data via JSON")
  37. .termsOfServiceUrl("NO terms of service")
  38. .version("1.0")
  39. .contact(new Contact("yww@jkzl.com", "", ""))
  40. .license("The Apache License, Version 2.0")
  41. .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
  42. .build();
  43. }
  44. }