springfox.documentation.spi.DocumentationType Java Examples

The following examples show how to use springfox.documentation.spi.DocumentationType. 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: AbstractSwaggerConfig.java    From onetwo with Apache License 2.0 6 votes vote down vote up
protected Docket createDocket(String groupName, String applicationName, Collection<Predicate<RequestHandler>> packages){
	Docket docket = new Docket(DocumentationType.SWAGGER_2)
				.ignoredParameterTypes(ApiIgnore.class)
				.groupName(groupName)
				.alternateTypeRules(
						AlternateTypeRules.newRule(
								typeResolver.resolve(DeferredResult.class, typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
								typeResolver.resolve(WildcardType.class)
                              )
				)
		//		.pathProvider(pathProvider)
		        .select()
		            .apis(Predicates.or(packages))
		            .paths(PathSelectors.any())
		        .build()
		        .globalOperationParameters(createGlobalParameters())
		        .apiInfo(apiInfo(applicationName));
	
	addGlobalResponseMessages(docket);
	return docket;
}
 
Example #2
Source File: SwaggerConfig.java    From yshopmall with Apache License 2.0 6 votes vote down vote up
@Bean
@SuppressWarnings("all")
public Docket createRestApi() {
    ParameterBuilder ticketPar = new ParameterBuilder();
    List<Parameter> pars = new ArrayList<>();
    ticketPar.name(tokenHeader).description("token")
            .modelRef(new ModelRef("string"))
            .parameterType("header")
            .defaultValue(tokenStartWith + " ")
            .required(true)
            .build();
    pars.add(ticketPar.build());
    return new Docket(DocumentationType.SWAGGER_2)
            .enable(enabled)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage("co.yixiang.modules"))
            .paths(Predicates.not(PathSelectors.regex("/error.*")))
            .build()
            .globalOperationParameters(pars);
}
 
Example #3
Source File: SwaggerConfig.java    From yauaa with Apache License 2.0 6 votes vote down vote up
@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 #4
Source File: SwaggerConfiguration.java    From ServiceCutter with Apache License 2.0 6 votes vote down vote up
/**
 * Swagger Springfox configuration.
 */
@Bean
public Docket swaggerSpringfoxDocket() {
    log.debug("Starting Swagger");
    StopWatch watch = new StopWatch();
    watch.start();
    Docket docket = new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .genericModelSubstitutes(ResponseEntity.class)
        .forCodeGeneration(true)
        .genericModelSubstitutes(ResponseEntity.class)
        .directModelSubstitute(org.joda.time.LocalDate.class, String.class)
        .directModelSubstitute(org.joda.time.LocalDateTime.class, Date.class)
        .directModelSubstitute(org.joda.time.DateTime.class, Date.class)
        .directModelSubstitute(java.time.LocalDate.class, String.class)
        .directModelSubstitute(java.time.ZonedDateTime.class, Date.class)
        .directModelSubstitute(java.time.LocalDateTime.class, Date.class)
        .select()
        .paths(regex(DEFAULT_INCLUDE_PATTERN))
        .build();
    watch.stop();
    log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
    return docket;
}
 
Example #5
Source File: Swagger2Config.java    From sophia_scaffolding with 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 #6
Source File: SwaggerConfig.java    From springboot-example with Apache License 2.0 6 votes vote down vote up
@Bean
public Docket swaggerSpringMvcPlugin() {
    ApiInfo apiInfo = new ApiInfo(
            "Spring Boot APIs",
            "Spring Boot + Swagger2",
            "1.0.0",
            null,
            "王磊的博客",
            "作者:王磊",
            "http://www.apigo.cn/");
    Docket docket = new Docket(DocumentationType.SWAGGER_2)
            .select()
            .paths(regex("/api/.*"))
            .build()
            .apiInfo(apiInfo)
            .useDefaultResponseMessages(false);
    return docket;
}
 
Example #7
Source File: SwaggerConfig.java    From java-pay with 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 #8
Source File: Swagger2Config.java    From lion with Apache License 2.0 6 votes vote down vote up
/**
 * 访问地址:http://ip:port/doc.html
 */
@Bean
public Docket api() {
    Docket docket = new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .groupName(version)
            .select()
            //设置包路径
            .apis(RequestHandlerSelectors.basePackage("com." + applicationName.replace("-", ".")))
            //.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
            .paths(PathSelectors.any())
            //.paths(PathSelectors.regex("/lion.*"))
            .build()
            .securityContexts(Lists.newArrayList(securityContext()))
            .securitySchemes(Lists.<SecurityScheme>newArrayList(apiKey()));
    return docket;
}
 
Example #9
Source File: SwaggerConfig.java    From supplierShop with MIT License 6 votes vote down vote up
/**
 * 创建API
 */
@Bean
public Docket createRestApi()
{
    return new Docket(DocumentationType.SWAGGER_2)
            // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息)
            .apiInfo(apiInfo())
            // 设置哪些接口暴露给Swagger展示
            .select()
            // 扫描所有有注解的api,用这种方式更灵活
            .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
            // 扫描指定包中的swagger注解
            //.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
            // 扫描所有 .apis(RequestHandlerSelectors.any())
            .paths(PathSelectors.any())
            .build();
}
 
Example #10
Source File: SwaggerConfig.java    From pig with MIT License 6 votes vote down vote up
@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 #11
Source File: SwaggerConfig.java    From myth with Apache License 2.0 5 votes vote down vote up
/**
 * Api docket.
 *
 * @return the docket
 */
@Bean
public Docket api() {
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
            // .paths(paths())
            .build().pathMapping("/").directModelSubstitute(LocalDate.class, String.class)
            .genericModelSubstitutes(ResponseEntity.class).useDefaultResponseMessages(false)
            .globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message")
                    .responseModel(new ModelRef("Error")).build()));
}
 
Example #12
Source File: SwaggerConfig.java    From SpringCloud with 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.springboot.cloud.gateway.admin"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #13
Source File: SwaggerConfig.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
@Bean
public Docket api() { 
    return new Docket(DocumentationType.SWAGGER_2)
    		.apiInfo(apiInfo)
    		.select()               
    		.apis(RequestHandlerSelectors.basePackage("org.eclipse.scava.presentation.rest"))              
    		.paths(PathSelectors.any())                          
    		.build();                                          
}
 
Example #14
Source File: SwaggerConfig.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public Docket postsApi() {
    return new Docket(DocumentationType.SWAGGER_2).groupName("public-api")
            .apiInfo(apiInfo())
            .select()
                .apis(RequestHandlerSelectors.basePackage("com.automationintesting.api"))
                .paths(PathSelectors.any())
            .build();
}
 
Example #15
Source File: SwaggerConfig.java    From cloud-transfer-backend with MIT License 5 votes vote down vote up
@Bean
public Docket api() {
	return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false).select()
			.apis(RequestHandlerSelectors
					.basePackage("com.github.dhavalmehta1997.savetogoogledrive.controller.rest"))
			.paths(PathSelectors.any()).build().apiInfo(apiInfo());
}
 
Example #16
Source File: OpenAPIDocumentationConfig.java    From openapi-generator with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket customImplementation(ServletContext servletContext, @Value("${openapi.openAPIPetstore.base-path:/v2}") String basePath) {
    return new Docket(DocumentationType.SWAGGER_2)
            .select()
                .apis(RequestHandlerSelectors.basePackage("org.openapitools.api"))
                .build()
            .pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath))
            .directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
            .directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
            .apiInfo(apiInfo());
}
 
Example #17
Source File: Application.java    From springfox-demos with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket petApi() {
  return new Docket(DocumentationType.SWAGGER_2)
      .groupName("full-petstore-api")
      .apiInfo(apiInfo())
      .select()
      .paths(petstorePaths())
      .build()
      .securitySchemes(Collections.singletonList(oauth()))
      .securityContexts(Collections.singletonList(securityContext()));
}
 
Example #18
Source File: SwaggerConfig.java    From SpringAll with MIT License 5 votes vote down vote up
@Bean
public Docket buildDocket() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(buildApiInf())
            .select()
            .apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #19
Source File: SwaggerConfig.java    From cloud-service with MIT License 5 votes vote down vote up
@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 #20
Source File: SwaggerConfig.java    From springfox-oath2-demo with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket postsApi() {
	return new Docket(DocumentationType.SWAGGER_2).groupName("public-api")
			.apiInfo(apiInfo()).select().paths(postPaths())
			.apis(Predicates.not(RequestHandlerSelectors.basePackage("org.springframework.boot")))	
			.paths(springBootActuatorJmxPaths())
			.build()		
			.securitySchemes(Collections.singletonList(oauth()))
	;
}
 
Example #21
Source File: FebsDocAutoConfigure.java    From FEBS-Cloud with Apache License 2.0 5 votes vote down vote up
@Bean
@Order(-1)
public Docket groupRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(groupApiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage(properties.getBasePackage()))
            .paths(PathSelectors.any())

            .build().securityContexts(Lists.newArrayList(securityContext())).securitySchemes(Lists.<SecurityScheme>newArrayList(apiKey()));
}
 
Example #22
Source File: Swagger2.java    From Demo with 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.nasus.controller"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #23
Source File: Swagger2.java    From Resource with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public Docket createdRestApi()
{
    return new Docket(DocumentationType.SWAGGER_2)
        .apiInfo(apiInfo())
        .select()
        //为当前包路径
        .apis(RequestHandlerSelectors.basePackage("com.zsm.sb.controller"))
        .paths(PathSelectors.any())
        .build();
}
 
Example #24
Source File: SwaggerConfiguration.java    From spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean
@Primary
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(apiInfo())
            .select()
            .apis(RequestHandlerSelectors.basePackage(api))
            .paths(PathSelectors.any())
            .build();
}
 
Example #25
Source File: SwaggerConfig.java    From SpringCloud with 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.springboot.cloud.demos.producer"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #26
Source File: SwaggerConfiguration.java    From SwaggerOfflineDoc with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket buildDocket() {
    return new Docket(DocumentationType.SWAGGER_2)
            .apiInfo(buildApiInfo())
            .select()
            //要扫描的API(Controller)基础包
            .apis(RequestHandlerSelectors.basePackage("com.swagger.offline.controller"))
            .paths(PathSelectors.any())
            .build();
}
 
Example #27
Source File: SwaggerConfig.java    From spring-web-services with MIT License 5 votes vote down vote up
@Bean
public Docket api() {
	return new Docket(DocumentationType.SWAGGER_2)
			.apiInfo(DEFAULT_API_INFO)
			.produces(DEFAULT_PRODUCES_AND_CONSUMES)
			.consumes(DEFAULT_PRODUCES_AND_CONSUMES);
}
 
Example #28
Source File: Swagger2Config.java    From open-capacity-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public Docket createRestApi() {
    return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) //创建API基本信息
            .groupName("") //指定分组,对应(/v2/api-docs?group=)
            .pathMapping("") //base地址,最终会拼接Controller中的地址
            .select() //控制要暴露的接口
            .apis(RequestHandlerSelectors.basePackage("com.shaoytsh.spinrgbootwebproject.controller")) //通过指定扫描包暴露接口
            .paths(PathSelectors.any()) //设置过滤规则暴露接口
            .build();
}
 
Example #29
Source File: Swagger2.java    From danyuan-application with 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("tk.ainiyue.danyuan"))
	        .paths(PathSelectors.any())
	        .build();
}
 
Example #30
Source File: SwaggerConfig.java    From Spring-Blog with 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.charles.api.controller"))
            .paths(PathSelectors.any())
            .build();
}