本文整理匯總了Java中springfox.documentation.spring.web.plugins.Docket類的典型用法代碼示例。如果您正苦於以下問題:Java Docket類的具體用法?Java Docket怎麽用?Java Docket使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Docket類屬於springfox.documentation.spring.web.plugins包,在下文中一共展示了Docket類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: productsApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket productsApi() {
return new Docket(DocumentationType.SWAGGER_2)
.globalOperationParameters(
newArrayList(new ParameterBuilder()
.name("Authorization")
.description("Bearer your_token ")
.modelRef(new ModelRef("string"))
.parameterType("header")
.build()))
.apiInfo(apiInfo())
//.pathMapping("/")
.select()
//.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("/api.*"))
.paths(PathSelectors.any())
.build();
}
示例2: createRestApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)
.additionalModels(typeResolver.resolve(ErrorInfo.class))
.globalResponseMessage(RequestMethod.GET, getDefaultResponseMessage())
.globalResponseMessage(RequestMethod.POST, getDefaultResponseMessage())
.globalResponseMessage(RequestMethod.PUT, getDefaultResponseMessage())
.globalResponseMessage(RequestMethod.DELETE, getDefaultResponseMessage())
.directModelSubstitute(Timestamp.class, Date.class)
.tags(new Tag("默認標簽", "定義全局默認標簽"),getTags())
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.plumdo.form"))
.paths(PathSelectors.any())
.build();
}
示例3: thingsboardApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket thingsboardApi() {
TypeResolver typeResolver = new TypeResolver();
final ResolvedType jsonNodeType =
typeResolver.resolve(
JsonNode.class);
final ResolvedType stringType =
typeResolver.resolve(
String.class);
return new Docket(DocumentationType.SWAGGER_2)
.groupName("iotp")
.apiInfo(apiInfo())
.alternateTypeRules(
new AlternateTypeRule(
jsonNodeType,
stringType))
.select()
.paths(apiPaths())
.build()
.securitySchemes(newArrayList(jwtTokenKey()))
.securityContexts(newArrayList(securityContext()));
}
示例4: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.regex("/documents(.*)"))
.build()
.globalOperationParameters(
Stream.of(new ParameterBuilder()
.name("Authorization")
.description("User Auth")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build()).collect(Collectors.toList()))
.globalOperationParameters(
Stream.of(new ParameterBuilder()
.name("ServiceAuthorization")
.description("Service Auth. Use it when accessing the API on App Tier level.")
.modelRef(new ModelRef("string"))
.parameterType("header")
.required(true)
.build()).collect(Collectors.toList()))
.apiInfo(apiInfo());
}
示例5: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
/**
* Controllers API doc. Note: Error controllers are excluded for brevity.
*
* @return {@link Docket}
*/
@Bean
public Docket api(OneOpsConfig config) {
log.info("Configuring OneOps Secret API documentation.");
List<Parameter> headers = singletonList(new ParameterBuilder()
.name(config.getAuth().getHeader())
.description("Authorization token header")
.modelRef(new ModelRef("string"))
.parameterType("header")
.defaultValue("Bearer [Auth Token]")
.required(true)
.build());
return new Docket(SWAGGER_2)
.groupName("secrets")
.ignoredParameterTypes(OneOpsUser.class)
.globalOperationParameters(headers)
.apiInfo(apiInfo())
.select()
.apis(basePackage(RootController.class.getPackage().getName()))
.paths(regex("^(?!/error).*$")) // Ignore all '/error' handlers.
.build();
}
示例6: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(new ApiInfo(
"Smarti",
"the smart in assistify",
apiVersion,
null,
new Contact(
apiContactName,
apiContactUrl,
"[email protected]"
),
"Apache 2.0",
"https://www.apache.org/licenses/LICENSE-2.0",
Collections.emptyList()
))
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.any())
.build()
.securitySchemes(Arrays.asList(authToken(), basicAuth()))
.securityContexts(Arrays.asList(publicContext(), defaultContext()))
.ignoredParameterTypes(AuthContext.class)
.directModelSubstitute(ObjectId.class, String.class);
}
示例7: swaggerDocket
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket swaggerDocket() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(getApiInfo())
.globalOperationParameters(Collections.singletonList(
new ParameterBuilder()
.name("Authorization")
.description("Provide if necessary")
.modelRef(new ModelRef("string"))
.parameterType("header")
.build()))
.forCodeGeneration(true)
.select()
.paths(regex(DEFAULT_INCLUDE_PATTERN))
.build();
}
示例8: practiceApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket practiceApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.sdcuike.practice"))
.paths(PathSelectors.any())
.build()
.pathMapping("/")
.genericModelSubstitutes(ResponseEntity.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)))
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET,
newArrayList(new ResponseMessageBuilder()
.code(500)
.message("500 message")
.responseModel(new ModelRef("Error"))
.build()))
.enableUrlTemplating(true)
.tags(new Tag("Pet Service", "All apis relating to pets"));
}
示例9: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)//
.select()//
.apis(RequestHandlerSelectors.any())//
.paths(Predicates.not(PathSelectors.regex("/error")))//
.build()//
.apiInfo(metadata())//
.useDefaultResponseMessages(false)//
.securitySchemes(new ArrayList<>(Arrays.asList(new ApiKey("Bearer %token", "Authorization", "Header"))))//
.tags(new Tag("users", "Operations about users"))//
.tags(new Tag("ping", "Just a ping"))//
.genericModelSubstitutes(Optional.class);
}
示例10: createRestApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.bootcwenao.feignserver.controller"))
.paths(PathSelectors.any())
.build();
}
示例11: createRestApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("org.prcode.web"))
.paths(PathSelectors.any())
.build();
}
示例12: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@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()));
}
示例13: api
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
示例14: createRestApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
@Bean
public Docket createRestApi()
{
Docket curSwaggerConfigDocket = new Docket(DocumentationType.SWAGGER_2)
.groupName(SERVICE_GROUP_NAME_STR) /** set SwaggerUI current project(Service) name */
.useDefaultResponseMessages(false) /** refuse the default response mode */
.forCodeGeneration(true) /** set good type for API Document code */
.select() /** set the path where build the document */
.apis(RequestHandlerSelectors.basePackage(SWAGGER_SCAN_BASE_PACKAGE_PATH)) /** set the path for the scanning of API,default as apis(RequestHandlerSelectors.any()) */
.paths(PathSelectors.any()) /** monitoring the api state */
.build()
.apiInfo(testApiInfo());
return curSwaggerConfigDocket;
}
示例15: productApi
import springfox.documentation.spring.web.plugins.Docket; //導入依賴的package包/類
/**
* Configure Spring Fox.
*
* @return The spring fox docket.
*/
@Bean
public Docket productApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.web.web.controller"))
.paths(any())
.build()
.apiInfo(metaData());
}