本文整理汇总了Java中springfox.documentation.RequestHandler类的典型用法代码示例。如果您正苦于以下问题:Java RequestHandler类的具体用法?Java RequestHandler怎么用?Java RequestHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RequestHandler类属于springfox.documentation包,在下文中一共展示了RequestHandler类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: basePackages
import springfox.documentation.RequestHandler; //导入依赖的package包/类
@SuppressWarnings("unused")
private static final Predicate<RequestHandler> basePackages(final Class<?>... classes)
{
final Set<Predicate<RequestHandler>> predicates = new HashSet<>(classes.length);
for (final Class<?> clazz : classes)
{
final String packageName = clazz.getPackage().getName();
predicates.add(RequestHandlerSelectors.basePackage(packageName));
}
if(predicates.size() == 1)
{
return predicates.iterator().next();
}
return Predicates.or(predicates);
}
示例2: api
import springfox.documentation.RequestHandler; //导入依赖的package包/类
@Bean
@Conditional(ActiveProfilesCondition.class)
public Docket api() {
ApiSelectorBuilder apiSelectorBuilder = new Docket(DocumentationType.SWAGGER_2).select();
Predicate<RequestHandler> predicate = RequestHandlerSelectors.basePackage(springfoxLoader.getBasePackage())::apply;
if (springfoxLoader.includeControllers().length > 0) {
Class<?>[] controllers = springfoxLoader.includeControllers();
for (Class<?> controller : controllers) {
Predicate<RequestHandler> includeControllerRequestHandler = RequestHandlerSelectors.basePackage(controller.getPackage().getName())::apply;
predicate = predicate.or(includeControllerRequestHandler);
}
}
apiSelectorBuilder.apis(predicate::test);
apiSelectorBuilder.paths(PathSelectors.any()).build().apiInfo(apiInfo()).pathMapping(springfoxLoader.getPath());
return apiSelectorBuilder.build();
}
示例3: api
import springfox.documentation.RequestHandler; //导入依赖的package包/类
@Bean
public Docket api(){
Set<Predicate<RequestHandler>> packages = Sets.newHashSet();
packages.addAll(getPluginBasePackages());
String scanPackageName = getScanPackageName();//ClassUtils.getPackageName(ServiceApplication.class);
if(StringUtils.isNotBlank(scanPackageName)){
packages.add(RequestHandlerSelectors.basePackage(scanPackageName));
}
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.ignoredParameterTypes(ApiIgnore.class)
// .pathProvider(pathProvider)
.select()
.apis(Predicates.or(packages))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
return docket;
}
示例4: apis
import springfox.documentation.RequestHandler; //导入依赖的package包/类
private Predicate<RequestHandler> apis(Swagger2Properties swagger2Properties) {
List<Predicate<RequestHandler>> basePackages = new LinkedList<>();
if (swagger2Properties.getBasePackage().isEmpty()) {
basePackages.add(RequestHandlerSelectors.any());
}
for (String basePackage : swagger2Properties.getBasePackage()) {
basePackages.add(RequestHandlerSelectors.basePackage(basePackage));
}
return Predicates.or(basePackages);
}
示例5: transform
import springfox.documentation.RequestHandler; //导入依赖的package包/类
private Predicate<RequestHandler> transform(final Predicate<String> pathSelector) {
return new Predicate<RequestHandler>() {
@Override
public boolean apply(RequestHandler input) {
return Iterables.any(input.getRequestMapping().getPatternsCondition().getPatterns(), pathSelector);
}
};
}
示例6: getDocket
import springfox.documentation.RequestHandler; //导入依赖的package包/类
/**
* Gets the docket.
*
* @param groupName the group name
* @param pathPattern the path pattern
* @param apis the apis
* @param apiinfo the apiinfo
* @param tag the tag
* @return the docket
*/
private Docket getDocket(
String groupName,
Predicate<String> pathPattern,
Predicate<RequestHandler> apis,
ApiInfo apiinfo,
Tag tag) {
return new Docket(DocumentationType.SWAGGER_2)
.groupName(groupName)
.select()
.apis(apis)
.paths(pathPattern)
.build()
.apiInfo(apiinfo)
.pathMapping("/")
.directModelSubstitute(LocalDate.class, String.class)
.genericModelSubstitutes(ResponseEntity.class)
.alternateTypeRules(
new AlternateTypeRule(
typeResolver.resolve(
DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)))
.useDefaultResponseMessages(false)
.enableUrlTemplating(false)
.tags(tag);
}
示例7: getterMethods
import springfox.documentation.RequestHandler; //导入依赖的package包/类
/**
* Gets the ter methods.
*
* @return the ter methods
*/
private Predicate<RequestHandler> getterMethods() {
return input -> {
Set<RequestMethod> methods = input.supportedMethods();
return CollectionUtils.isEmpty(methods) || methods.contains(RequestMethod.GET);
};
}
示例8: setup
import springfox.documentation.RequestHandler; //导入依赖的package包/类
@Before
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
Method method = this.getClass().getMethod("test", new Class<?>[] { Pageable.class, Integer.class });
RequestHandler handler = new WebMvcRequestHandler(null, new HandlerMethod(this, method));
DocumentationContext docContext = mock(DocumentationContext.class);
RequestMappingContext reqContext = new RequestMappingContext(docContext, handler);
builder = spy(new OperationBuilder(null));
context = new OperationContext(builder, RequestMethod.GET, reqContext, 0);
resolver = new TypeResolver();
List<TypeNameProviderPlugin> plugins = new LinkedList<>();
extractor = new TypeNameExtractor(resolver, SimplePluginRegistry.create(plugins));
plugin = new PageableParameterBuilderPlugin(extractor, resolver);
}
示例9: getPluginBasePackages
import springfox.documentation.RequestHandler; //导入依赖的package包/类
protected Set<Predicate<RequestHandler>> getPluginBasePackages(){
if(pluginManager!=null){
return pluginManager.getPlugins()
.stream()
.map(p->RequestHandlerSelectors.basePackage(ClassUtils.getPackageName(p.getRootClass())))
.collect(Collectors.toSet());
}
return Collections.emptySet();
}
示例10: modelApiHandlerPredicate
import springfox.documentation.RequestHandler; //导入依赖的package包/类
private Predicate<RequestHandler> modelApiHandlerPredicate() {
return and(
withClassAnnotation(RepositoryRestController.class)
);
}
示例11: combine
import springfox.documentation.RequestHandler; //导入依赖的package包/类
private Predicate<RequestHandler> combine(Predicate<RequestHandler> requestHandlerSelector, Predicate<String> pathSelector) {
return Predicates.and(requestHandlerSelector, transform(pathSelector));
}
示例12: apply
import springfox.documentation.RequestHandler; //导入依赖的package包/类
@Override
public boolean apply(RequestHandler input)
{
return input.produces().contains(MediaType.APPLICATION_JSON);
}