Swagger2.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package com.fdkankan.common.base;
  2. import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
  3. import org.springframework.context.annotation.Bean;
  4. import org.springframework.context.annotation.Configuration;
  5. import springfox.documentation.builders.ApiInfoBuilder;
  6. import springfox.documentation.builders.PathSelectors;
  7. import springfox.documentation.builders.RequestHandlerSelectors;
  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. @EnableSwagger2
  13. @EnableSwaggerBootstrapUI
  14. @Configuration
  15. public class Swagger2 {
  16. @Bean
  17. public Docket baseApi() {
  18. return new Docket(DocumentationType.SWAGGER_2).groupName("模板接口").apiInfo(apiBaseInfo()).select().apis(RequestHandlerSelectors.basePackage("com.fdkankan"))
  19. .paths(PathSelectors.regex(".*/base/.*")).build();
  20. }
  21. private ApiInfo apiBaseInfo() {
  22. return new ApiInfoBuilder().title("模板接口文档").description("模板接口文档").termsOfServiceUrl("").version("1.0").build();
  23. }
  24. @Bean
  25. public Docket createRestApi() {
  26. return new Docket(DocumentationType.SWAGGER_2).groupName("API管理接口").apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.fdkankan"))
  27. .paths(PathSelectors.regex(".*/.*")).build();
  28. }
  29. private ApiInfo apiInfo() {
  30. return new ApiInfoBuilder().title("API文档").description("API文档").termsOfServiceUrl("").version("1.0").build();
  31. }
  32. @Bean
  33. public Docket backApi() {
  34. return new Docket(DocumentationType.SWAGGER_2).groupName("后台管理接口").apiInfo(apiBackInfo()).select().apis(RequestHandlerSelectors.basePackage("com.fdkankan"))
  35. .paths(PathSelectors.regex(".*/back/.*")).build();
  36. }
  37. private ApiInfo apiBackInfo() {
  38. return new ApiInfoBuilder().title("后台管理接口").description("后台管理接口实现的文档").termsOfServiceUrl("").version("1.0").build();
  39. }
  40. }