springfox.documentation.builders.PathSelectors Java Examples

The following examples show how to use springfox.documentation.builders.PathSelectors. 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 Project: sophia_scaffolding   Author: SophiaLeo   File: Swagger2Config.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建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 #2
Source Project: java-pay   Author: janlle   File: SwaggerConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public Docket weiXinApi() {
    Parameter parameter = new ParameterBuilder()
            .name("Authorization")
            .description("token")
            .modelRef(new ModelRef("string"))
            .parameterType("header")
            .required(false)
            .defaultValue("token ")
            .build();

    return new Docket(DocumentationType.SWAGGER_2)
            .groupName("微信API接口文档")
            .globalOperationParameters(Collections.singletonList(parameter))
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.andy.pay.wx"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #3
Source Project: spring-boot-plus   Author: geekidea   File: Swagger2Config.java    License: Apache License 2.0 6 votes vote down vote up
@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 #4
Source Project: XS2A-Sandbox   Author: adorsys   File: CertificateSwaggerConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public Docket apiDocket() {
    return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(new ApiInfoBuilder()
                            .title("Certificate Generator")
                            .description("Certificate Generator for Testing Purposes of PSD2 Sandbox Environment")
                            .contact(new Contact(
                                "adorsys GmbH & Co. KG",
                                "https://adorsys.de",
                                "[email protected]"))
                            .version(buildProperties.getVersion() + " " + buildProperties.get("build.number"))
                            .build())
               .groupName("Certificate Generator API")
               .select()
               .apis(RequestHandlerSelectors.basePackage("de.adorsys.psd2.sandbox.certificate"))
               .paths(PathSelectors.any())
               .build();
}
 
Example #5
Source Project: XS2A-Sandbox   Author: adorsys   File: TppSwaggerConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
public Docket apiDocklet() {
    return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(new ApiInfoBuilder()
                            .title("TPP backend application")
                            .description("TPP backend application of PSD2 Sandbox Environment")
                            .contact(new Contact(
                                "Adorsys GmbH & Co. KG",
                                "https://adorsys.de",
                                "[email protected]")
                            )
                            .version(buildProperties.getVersion() + " " + buildProperties.get("build.number"))
                            .build())
               .groupName("TPP-API")
               .select()
               .apis(RequestHandlerSelectors
                         .basePackage("de.adorsys.psd2.sandbox.tpp.rest"))
               .paths(PathSelectors.any())
               .build()
               .securitySchemes(singletonList(securitySchema()));
}
 
Example #6
/**
 * 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 #7
/**
 * 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 #8
Source Project: mPaaS   Author: lihangqi   File: SwaggerConfig.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 动态产生Docket分组信息
 *
 * @return
 */
@Autowired
public void dynamicConfiguration() {
    ConfigurableApplicationContext context = (ConfigurableApplicationContext) applicationContext;
    DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) context.getBeanFactory();

    String systemName = "Microservice PaaS";
    ApiInfoBuilder apiInfoBuilder = new ApiInfoBuilder()
            .description("mPaas前端后端对应接口")
            .version("1.0.1")
            .license("Code Farmer Framework(iByte) Org.");

    Map<String, ModuleMappingInfo> moduleInfo = mappingHelper.getMappingInfos();
    for (Map.Entry<String, ModuleMappingInfo> entry : moduleInfo.entrySet()) {
        beanFactory.registerSingleton(entry.getKey(), new Docket(DocumentationType.SWAGGER_2)
                .groupName(entry.getKey())
                .apiInfo(apiInfoBuilder.title(systemName + NamingConstant.DOT + entry.getKey()).build())
                .select()
                .apis(genSubPackage(entry.getKey()))
                .paths(Predicates.or(PathSelectors.ant(NamingConstant.PATH_PREFIX_DATA + "/**"),
                        PathSelectors.ant(NamingConstant.PATH_PREFIX_API + "/**")))
                .build());
    }
}
 
Example #9
Source Project: sophia_scaffolding   Author: SophiaLeo   File: Swagger2Config.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 创建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 #10
Source Project: swagger-more   Author: uhfun   File: SwaggerConfig.java    License: Apache License 2.0 6 votes vote down vote up
@Bean
@Autowired
public Docket complete(ServletContext servletContext) {
    List<ResponseMessage> responseMessageList = newArrayList();
    return new Docket(SWAGGER_2)
            .pathProvider(new RelativePathProvider(servletContext) {
                @Override
                public String getApplicationBasePath() {
                    return "/dubbo";
                }
            })
            .apiInfo(apiInfo())
            .select()
            .apis(ExtendRequestHandlerSelectors.dubboApi())
            .paths(PathSelectors.any())
            .build()
            .groupName("dubbo")
            .produces(Sets.newHashSet("application/json", "text/plain"))
            .consumes(Collections.singleton("application/json"))
            .useDefaultResponseMessages(false)
            .globalResponseMessage(RequestMethod.GET, responseMessageList)
            .globalResponseMessage(RequestMethod.POST, responseMessageList);
}
 
Example #11
Source Project: spring-cloud-learning   Author: coderqianlq   File: Swagger2Config.java    License: MIT License 6 votes vote down vote up
@Bean
public Docket createRestApi() {

    ParameterBuilder tokenPar = new ParameterBuilder();
    List<Parameter> pars = new ArrayList<Parameter>();
    tokenPar.name("x-access-token").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.qianlq.core.controller"))
            .paths(PathSelectors.any())
            .build()
            .globalOperationParameters(pars);
}
 
Example #12
/**
 * 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 #13
Source Project: HIS   Author: ZainZhao   File: Swagger2Config.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.neu.his.cloud.service.bms.controller"))
                .paths(PathSelectors.any())
                .build();
//                .securitySchemes(securitySchemes())
//                .securityContexts(securityContexts());
    }
 
Example #14
Source Project: flow-platform-x   Author: gy2006   File: SwaggerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2)
        .select()
        .apis(RequestHandlerSelectors.basePackage("com.flowci.core"))
        .paths(PathSelectors.any())
        .build();
}
 
Example #15
Source Project: HIS   Author: ZainZhao   File: Swagger2Config.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket createRestApi(){
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.neu.his.cloud.zuul.controller"))
            .paths(PathSelectors.any())
            .build()
            .securitySchemes(securitySchemes())
            .securityContexts(securityContexts());
}
 
Example #16
Source Project: data-highway   Author: HotelsDotCom   File: OnrampSwaggerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket onrampSwagger() {
  return new Docket(SWAGGER_2)
      .groupName("onramp")
      .securitySchemes(Collections.singletonList(new BasicAuth(BASIC_AUTH)))
      .securityContexts(Collections.singletonList(securityContext()))
      .apiInfo(new ApiInfoBuilder().title("Onramp").build())
      .useDefaultResponseMessages(false)
      .tags(new Tag("onramp", "Submit messages"))
      .select()
      .apis(RequestHandlerSelectors.any())
      .paths(PathSelectors.regex("/onramp.*"))
      .build();
}
 
Example #17
Source Project: data-highway   Author: HotelsDotCom   File: PaverSwaggerConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket paverSwagger() {
  return new Docket(SWAGGER_2)
      .groupName("paver")
      .securitySchemes(Collections.singletonList(new BasicAuth(BASIC_AUTH)))
      .securityContexts(Collections.singletonList(securityContext()))
      .apiInfo(new ApiInfoBuilder().title("Paver").build())
      .useDefaultResponseMessages(false)
      .tags(new Tag("road", "Administer roads"), new Tag("schema", "Administer schemas"))
      .select()
      .apis(RequestHandlerSelectors.any())
      .paths(PathSelectors.regex("/paver.*"))
      .build();
}
 
Example #18
Source Project: Learning-Path-Spring-5-End-to-End-Programming   Author: PacktPublishing   File: SwaggerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public Docket documentation() {
  return new Docket(DocumentationType.SWAGGER_2)
      .select()
      .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
      .paths(PathSelectors.any())
      .build();
}
 
Example #19
Source Project: SpringBootBucket   Author: yidao620c   File: Swagger2Config.java    License: MIT License 5 votes vote down vote up
@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .produces(Sets.newHashSet("application/json"))
                .consumes(Sets.newHashSet("application/json"))
                .protocols(Sets.newHashSet("http", "https"))
                .apiInfo(apiInfo())
                .forCodeGeneration(true)
                .select()
                // 指定controller存放的目录路径
                .apis(RequestHandlerSelectors.basePackage("com.xncoding.jwt.api"))
//                .paths(PathSelectors.ant("/api/v1/*"))
                .paths(PathSelectors.any())
                .build();
    }
 
Example #20
Source Project: poseidon   Author: Saseke   File: SwaggerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket createRestApi() {
	return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
			.apis(RequestHandlerSelectors
					.basePackage("com.yoke.poseidon.cart.web"))
			.paths(PathSelectors.any()).build();
}
 
Example #21
Source Project: mall-learning   Author: macrozheng   File: Swagger2Config.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                //为当前包下controller生成API文档
                .apis(RequestHandlerSelectors.basePackage("com.macro.mall.tiny.controller"))
                //为有@Api注解的Controller生成API文档
//                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                //为有@ApiOperation注解的方法生成API文档
//                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }
 
Example #22
Source Project: api-boot   Author: minbox-projects   File: ApiBootSwaggerAutoConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 配置swagger基本信息
 * - BasePackage
 * 默认使用SpringBoot项目扫描bean根目录
 * 如果存在配置时则使用SwaggerProperties.basePackage作为扫描根目录
 *
 * @return Docket实例
 */
@Bean
public Docket docket() {
    String basePackage = swaggerProperties.getBasePackage();
    if (StringUtils.isEmpty(basePackage)) {
        basePackage = AutoConfigurationPackages.get(beanFactory).get(0);
    }
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).securitySchemes(Collections.singletonList(apiKey())).securityContexts(Collections.singletonList(securityContext())).select().apis(RequestHandlerSelectors.basePackage(basePackage)).paths(PathSelectors.any()).build();
}
 
Example #23
Source Project: withme3.0   Author: IcedSoul   File: SwaggerConfig.java    License: MIT License 5 votes vote down vote up
@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("cn.icedsoul.groupservice"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #24
Source Project: jt808-server   Author: yezhihao   File: SwaggerConfig.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket customImplementation() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("org.yzh.web.controller"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #25
Source Project: casquatch   Author: tmobile   File: SpringRestApplication.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket api() {
	return new Docket(DocumentationType.SWAGGER_2)
			.select()
			.apis(RequestHandlerSelectors.basePackage("com.tmobile.opensource.casquatch.examples.springrest"))
			.paths(PathSelectors.any())
			.build();
}
 
Example #26
Source Project: parker   Author: wu-boy   File: Swagger2.java    License: MIT License 5 votes vote down vote up
@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.wu.parker"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #27
Source Project: e   Author: fuhoujun   File: SingleApplicationMain.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public Docket api() {
	ParameterBuilder tokenPar = new ParameterBuilder();
	List<springfox.documentation.service.Parameter> pars = new ArrayList<springfox.documentation.service.Parameter>();
	tokenPar.name("Authorization").description("令牌").modelRef(new ModelRef("string")).parameterType("header")
			.required(false).build();
	pars.add(tokenPar.build());

	return new Docket(DocumentationType.SWAGGER_2).select()
			.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)).paths(PathSelectors.any())
			.build().globalOperationParameters(pars);

}
 
Example #28
Source Project: mall-swarm   Author: macrozheng   File: Swagger2Config.java    License: Apache License 2.0 5 votes vote down vote up
@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()
            .securitySchemes(securitySchemes())
            .securityContexts(securityContexts());
}
 
Example #29
Source Project: Spring-5.0-By-Example   Author: PacktPublishing   File: SwaggerConfiguration.java    License: MIT License 5 votes vote down vote up
@Bean
public Docket documentation() {
  return new Docket(DocumentationType.SWAGGER_2)
      .select()
      .apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
      .paths(PathSelectors.any())
      .build();
}
 
Example #30
Source Project: oauth2-resource   Author: jobmission   File: Swagger2Configuration.java    License: MIT License 5 votes vote down vote up
@Bean
    public Docket createRestApi() {
        ParameterBuilder aParameterBuilder = new ParameterBuilder();
        aParameterBuilder
            .name("Authorization")
            .description("Authorization")
            .modelRef(new ModelRef("string"))
            .parameterType("header")
            .description("Bearer授权模式,'Bearer '开始")
            .required(false)
            .build()
        ;

        List<Parameter> aParameters = new ArrayList<>();
        aParameters.add(aParameterBuilder.build());

        return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .ignoredParameterTypes(Principal.class)
            .ignoredParameterTypes(JwtAuthenticationToken.class)
//            .globalOperationParameters(aParameters)
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.revengemission.sso.oauth2.resource.coupon.controller"))
            .paths(PathSelectors.any())
            .build()
            .securitySchemes(securitySchemes())
            .securityContexts(securityContexts());
    }