springfox.documentation.spring.web.plugins.Docket Java Examples
The following examples show how to use
springfox.documentation.spring.web.plugins.Docket.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SwaggerConfiguration.java From api-layer with Eclipse Public License 2.0 | 7 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage("org.zowe.apiml.apicatalog.controllers.api")) .paths( PathSelectors.any() ) .build() .securitySchemes( Arrays.asList( new BasicAuth("LoginBasicAuth"), new ApiKey("CookieAuth", "apimlAuthenticationToken", "header") ) ) .apiInfo( new ApiInfo( apiTitle, apiDescription, apiVersion, null, null, null, null, Collections.emptyList() ) ); }
Example #2
Source File: SwaggerConfig.java From yauaa with Apache License 2.0 | 6 votes |
@Bean public Docket api() { final ArrayList<Response> responseMessages = new ArrayList<>(); responseMessages.add(new ResponseBuilder() .code("200") .description("Successfully parsed the provided input") .build()); responseMessages.add(new ResponseBuilder() .code("503") .description("Internal error, or Yauaa is currently still busy starting up.") .build()); return new Docket(DocumentationType.SWAGGER_2) .groupName("yauaa-v1") .select() .apis(withMethodAnnotation(ApiOperation.class)) .build() .globalResponses(GET, responseMessages) .globalResponses(POST, responseMessages) .apiInfo(apiInfo()); }
Example #3
Source File: Swagger2Config.java From sophia_scaffolding with Apache License 2.0 | 6 votes |
/** * 创建RestApi 并包扫描controller * @return */ @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) //分组名称 // .groupName("2.X版本") .select() // // 对所有api进行监控 // .apis(RequestHandlerSelectors.any()) .apis(RequestHandlerSelectors.basePackage(basePackage)) //不显示错误的接口地址 .paths(PathSelectors.any()) //错误路径不监控 .paths(Predicates.not(PathSelectors.regex("/error.*"))) // .build(); .build() .securityContexts(Lists.newArrayList(securityContext())).securitySchemes(Lists.<SecurityScheme>newArrayList(apiKey())); }
Example #4
Source File: SwaggerAutoConfiguration.java From albedo with GNU Lesser General Public License v3.0 | 6 votes |
/** * Springfox configuration for the API Swagger docs. * * @param swaggerCustomizers Swagger customizers * @param alternateTypeRules alternate type rules * @return the Swagger Springfox configuration */ @Bean @ConditionalOnMissingBean(name = "swaggerSpringfoxApiDocket") public Docket swaggerSpringfoxApiDocket(List<SwaggerCustomizer> swaggerCustomizers, ObjectProvider<AlternateTypeRule[]> alternateTypeRules) { log.debug(STARTING_MESSAGE); StopWatch watch = new StopWatch(); watch.start(); Docket docket = createDocket(); // Apply all SwaggerCustomizers orderly. swaggerCustomizers.forEach(customizer -> customizer.customize(docket)); // Add all AlternateTypeRules if available in spring bean factory. // Also you can add your rules in a customizer bean above. Optional.ofNullable(alternateTypeRules.getIfAvailable()).ifPresent(docket::alternateTypeRules); watch.stop(); log.debug(STARTED_MESSAGE, watch.getTotalTimeMillis()); return docket; }
Example #5
Source File: SwaggerConfiguration.java From api-layer with Eclipse Public License 2.0 | 6 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.ant("/api/v1/**")) .build() .apiInfo( new ApiInfo( apiTitle, apiDescription, apiVersion, null, null, null, null, Collections.emptyList() ) ); }
Example #6
Source File: SwaggerConfig.java From open-capacity-platform with Apache License 2.0 | 6 votes |
@Bean public Docket createRestApi() { ParameterBuilder tokenPar = new ParameterBuilder(); List<Parameter> pars = new ArrayList<>(); tokenPar.name("Authorization").description("令牌"). modelRef(new ModelRef("string")). parameterType("header").required(false).build(); pars.add(tokenPar.build()); return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() // .apis(RequestHandlerSelectors.basePackage("com.open.capacity")) .apis(RequestHandlerSelectors.any()) .paths( input ->PathSelectors.regex("/user.*").apply(input) || PathSelectors.regex("/permissions.*").apply(input) || PathSelectors.regex("/roles.*").apply(input) || PathSelectors.regex("/test.*").apply(input) ) // .paths(PathSelectors.any()) .build().globalOperationParameters(pars); }
Example #7
Source File: Swagger2Config.java From spring-boot-plus with Apache License 2.0 | 6 votes |
@Bean public Docket createRestApi() { // 获取需要扫描的包 String[] basePackages = getBasePackages(); ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select(); // 如果扫描的包为空,则默认扫描类上有@Api注解的类 if (ArrayUtils.isEmpty(basePackages)) { apiSelectorBuilder.apis(RequestHandlerSelectors.withClassAnnotation(Api.class)); } else { // 扫描指定的包 apiSelectorBuilder.apis(basePackage(basePackages)); } Docket docket = apiSelectorBuilder.paths(PathSelectors.any()) .build() .enable(swaggerProperties.isEnable()) .ignoredParameterTypes(ignoredParameterTypes) .globalOperationParameters(getParameters()); return docket; }
Example #8
Source File: ProductCompositeServiceApplication.java From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License | 6 votes |
/** * Will exposed on $HOST:$PORT/swagger-ui.html * * @return */ @Bean public Docket apiDocumentation() { return new Docket(SWAGGER_2) .select() .apis(basePackage("se.magnus.microservices.composite.product")) .paths(PathSelectors.any()) .build() .globalResponseMessage(POST, emptyList()) .globalResponseMessage(GET, emptyList()) .globalResponseMessage(DELETE, emptyList()) .apiInfo(new ApiInfo( apiTitle, apiDescription, apiVersion, apiTermsOfServiceUrl, new Contact(apiContactName, apiContactUrl, apiContactEmail), apiLicense, apiLicenseUrl, emptyList() )); }
Example #9
Source File: Swagger2Configuration.java From web-flash with MIT License | 6 votes |
@Bean public Docket createRestApi() { //添加head参数start ParameterBuilder tokenPar = new ParameterBuilder(); List<Parameter> pars = new ArrayList<Parameter>(); tokenPar.name("Authorization").description("Token").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); pars.add(tokenPar.build()); //添加head参数end return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("cn.enilu.flash.api.controller")) .paths(PathSelectors.any()) .build().globalOperationParameters(pars); }
Example #10
Source File: SwaggerConfig.java From j360-boot-app-all with Apache License 2.0 | 6 votes |
@Bean public Docket webApi() { return new Docket(DocumentationType.SWAGGER_2) .groupName("api") //.host() .genericModelSubstitutes(DeferredResult.class) //.genericModelSubstitutes(ResponseEntity.class) .useDefaultResponseMessages(false) .forCodeGeneration(false) .pathMapping("/") .select() //.paths(PathSelectors.regex("/api"))//过滤的接口 .build() .apiInfo(webApiInfo()) .securitySchemes(securitySchemes()) .securityContexts(securityContexts()); }
Example #11
Source File: SwaggerConfig.java From pacbot with Apache License 2.0 | 6 votes |
@Bean public Docket userApi() { List<ResponseMessage> list = new java.util.ArrayList<>(); list.add(new ResponseMessageBuilder().code(500).message("500 message").responseModel(new ModelRef("Result")) .build()); list.add(new ResponseMessageBuilder().code(401).message("Unauthorized").responseModel(new ModelRef("Result")) .build()); list.add(new ResponseMessageBuilder().code(406).message("Not Acceptable").responseModel(new ModelRef("Result")) .build()); return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.tmobile.pacman")) .paths(PathSelectors.any()).build() .securitySchemes(chooseSecuritSchema()) .securityContexts(chooseSecurityContext()) .globalResponseMessage(RequestMethod.GET, list).globalResponseMessage(RequestMethod.POST, list); }
Example #12
Source File: SwaggerConfig.java From pig with MIT License | 6 votes |
@Bean public Docket createRestApi() { ParameterBuilder tokenBuilder = new ParameterBuilder(); List<Parameter> parameterList = new ArrayList<>(); tokenBuilder.name("Authorization") .defaultValue("去其他请求中获取heard中token参数") .description("令牌") .modelRef(new ModelRef("string")) .parameterType("header") .required(true).build(); parameterList.add(tokenBuilder.build()); return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.any()) .build() .globalOperationParameters(parameterList); }
Example #13
Source File: SwaggerConfig.java From DimpleBlog with Apache License 2.0 | 6 votes |
/** * 创建API */ @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .enable(enabled) // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) .apiInfo(apiInfo()) // 设置哪些接口暴露给Swagger展示 .select() // 扫描所有有注解的api,用这种方式更灵活 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 扫描指定包中的swagger注解 //.apis(RequestHandlerSelectors.basePackage("com.dimple.project.tool.swagger")) // 扫描所有 .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() /* 设置安全模式,swagger可以设置访问token */ .securitySchemes(securitySchemes()) .securityContexts(securityContexts()) .pathMapping(pathMapping); }
Example #14
Source File: Swagger2Config.java From springboot_cwenao with MIT License | 5 votes |
@Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.bootcwenao.feignserver.controller")) .paths(PathSelectors.any()) .build(); }
Example #15
Source File: Swagger2.java From notes with Apache License 2.0 | 5 votes |
/** * 注入docket * @return: Docket * @author: fruiqi * @date: 19-2-18 下午6:20 */ @Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(createApiInfo()) .select() .apis(RequestHandlerSelectors.basePackage(swaggerProperties.getBasePacakge())) .paths(PathSelectors.any()) .build(); }
Example #16
Source File: Swagger2Config.java From macrozheng with Apache License 2.0 | 5 votes |
@Bean public Docket createRestApi(){ return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.macro.mall.portal.controller")) .paths(PathSelectors.any()) .build(); }
Example #17
Source File: SwaggerConfig.java From burp-rest-api with BSD 2-Clause "Simplified" License | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.regex("/burp.*")) .build() .useDefaultResponseMessages(false); }
Example #18
Source File: Swagger2.java From mogu_blog_v2 with Apache License 2.0 | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2). useDefaultResponseMessages(false) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.regex("^(?!auth).*$")) .build() .securitySchemes(securitySchemes()) .securityContexts(securityContexts()) ; }
Example #19
Source File: SwaggerConfig.java From poseidon with Apache License 2.0 | 5 votes |
@Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() .apis(RequestHandlerSelectors .basePackage("com.yoke.poseidon.member.web")) .paths(PathSelectors.any()).build(); }
Example #20
Source File: SwaggerConfig.java From cloud-service with MIT License | 5 votes |
@Bean public Docket docket() { return new Docket(DocumentationType.SWAGGER_2).groupName("文件中心swagger接口文档") .apiInfo(new ApiInfoBuilder().title("文件中心swagger接口文档") .contact(new Contact("allen", "", "[email protected]")).version("1.0").build()) .select().paths(PathSelectors.any()).build(); }
Example #21
Source File: Swagger2Config.java From jeecg-boot with Apache License 2.0 | 5 votes |
/** * swagger2的配置文件,这里可以配置swagger2的一些基本的内容,比如扫描的包等等 * * @return Docket */ @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //此包路径下的类,才生成接口文档 .apis(RequestHandlerSelectors.basePackage("org.jeecg.modules")) //加了ApiOperation注解的类,才生成接口文档 .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) .paths(PathSelectors.any()) .build() .securitySchemes(Collections.singletonList(securityScheme())); //.globalOperationParameters(setHeaderToken()); }
Example #22
Source File: SpringFoxApplication.java From springrestdoc with MIT License | 5 votes |
@Bean public Docket restApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .groupName("Module API") .select() // .paths(any()) // Otherwise we are including springboot actuator endpoints .paths(Predicates.and(ant("/**"), Predicates.not(ant("/error")), Predicates.not(ant("/management/**")), Predicates.not(ant("/management*")))) .build(); }
Example #23
Source File: SwaggerConfig.java From alcor with Apache License 2.0 | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.regex("(?!/error).+")) .paths(PathSelectors.regex("(?!/actuator).+")) .build(); }
Example #24
Source File: SwaggerConfiguration.java From cxf-spring-cloud-netflix-docker with MIT License | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build(); }
Example #25
Source File: SwaggerConfig.java From spring-security-oauth with MIT License | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2).select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() .securitySchemes(Arrays.asList(securityScheme())) .securityContexts(Arrays.asList(securityContext())); }
Example #26
Source File: SwaggerConfig.java From DBus with Apache License 2.0 | 5 votes |
@Bean public Docket customImplementation() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE)) .build() //.directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class) //.directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class) .apiInfo(apiInfo()); }
Example #27
Source File: ApiListingJsonScanner.java From Resource with GNU General Public License v3.0 | 5 votes |
private static com.google.common.base.Function<ApiDescription, ResourceGroup> toResourceGroups() { return new com.google.common.base.Function<ApiDescription, ResourceGroup>() { @Override public ResourceGroup apply(ApiDescription input) { return new ResourceGroup( input.getGroupName().or(Docket.DEFAULT_GROUP_NAME), null); } }; }
Example #28
Source File: Swagger2.java From yes-cart with Apache License 2.0 | 5 votes |
@Bean public Docket api() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.regex("(?!/error).+")) .paths(PathSelectors.regex("(?!/connector).+")) .build() .apiInfo(apiInfo()); }
Example #29
Source File: Swagger2.java From parker with MIT License | 5 votes |
@Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.wu.parker")) .paths(PathSelectors.any()) .build(); }
Example #30
Source File: WxSwagger2Configuration.java From litemall with MIT License | 5 votes |
@Bean public Docket wxDocket() { return new Docket(DocumentationType.SWAGGER_2) .groupName("wx") .apiInfo(wxApiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("org.linlinjava.litemall.wx.web")) .paths(PathSelectors.any()) .build(); }