| | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import springfox.documentation.RequestHandler; |
| | | import springfox.documentation.builders.ApiInfoBuilder; |
| | | import springfox.documentation.builders.ParameterBuilder; |
| | | import springfox.documentation.builders.PathSelectors; |
| | | import springfox.documentation.oas.annotations.EnableOpenApi; |
| | | import springfox.documentation.schema.ModelRef; |
| | | import springfox.documentation.service.ApiInfo; |
| | | import springfox.documentation.service.Parameter; |
| | | import springfox.documentation.spi.DocumentationType; |
| | | import springfox.documentation.spring.web.plugins.Docket; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.function.Predicate; |
| | | |
| | | /** |
| | |
| | | .version(version) |
| | | .build(); |
| | | } |
| | | @Bean |
| | | public Docket getDocket3() { |
| | | /* @Bean |
| | | public Docket getDocket() { |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .apiInfo(this.getApiInfo()).groupName("【小程序接口API】") |
| | | .apiInfo(this.getApiInfo()).groupName("【系统管理接口API】") |
| | | .host(host) |
| | | .select() |
| | | .apis( basePackage("com.doumee.api.web")) |
| | | .apis( basePackage("com.doumee.api.system;")) |
| | | // 设置需要被扫描的类,这里设置为添加了@Api注解的类 |
| | | // .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build() |
| | | .globalOperationParameters(this.getParameterList()); |
| | | } |
| | | |
| | | private List<Parameter> getParameterList() { |
| | | ParameterBuilder tokenPar = new ParameterBuilder(); |
| | | List<Parameter> pars = new ArrayList<>(); |
| | | tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).defaultValue("设置token默认值").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); |
| | | pars.add(tokenPar.build()); |
| | | return pars; |
| | | } |
| | | |
| | | .build(); |
| | | }*/ |
| | | @Bean |
| | | public Docket getDocket1() { |
| | | public Docket getDocket2() { |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .apiInfo(this.getApiInfo()).groupName("【公共接口API】") |
| | | .apiInfo(this.getApiInfo()).groupName("default") |
| | | .host(host) |
| | | .select() |
| | | .apis( basePackage("com.doumee.api.common")) |
| | | .apis( basePackage("com.doumee.api.system;com.doumee.api.business;com.doumee.api.common")) |
| | | // 设置需要被扫描的类,这里设置为添加了@Api注解的类 |
| | | // .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build(); |
| | | } |
| | | /* @Bean |
| | | public Docket getDocket1() { |
| | | return new Docket(DocumentationType.SWAGGER_2) |
| | | .apiInfo(this.getApiInfo()).groupName("【公共接口API】") |
| | | .host(host) |
| | | .select() |
| | | .apis( basePackage("com.doumee.api.common")) |
| | | // 设置需要被扫描的类,这里设置为添加了@Api注解的类 |
| | | // .apis(RequestHandlerSelectors.withClassAnnotation(Api.class)) |
| | | .paths(PathSelectors.any()) |
| | | .build(); |
| | | }*/ |
| | | /** |
| | | * 重写basePackage方法,使能够实现多包访问,复制贴上去 |
| | | * @author teavamc |