com.fasterxml.classmate.TypeResolver Java Examples
The following examples show how to use
com.fasterxml.classmate.TypeResolver.
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: PageableParameterBuilderPluginTest.java From jhipster with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() throws Exception { MockitoAnnotations.initMocks(this); Method method = this.getClass().getMethod("test", new Class<?>[]{Pageable.class, Integer.class}); resolver = new TypeResolver(); RequestHandler handler = new WebMvcRequestHandler(new HandlerMethodResolver(resolver), 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); List<TypeNameProviderPlugin> plugins = new LinkedList<>(); extractor = new TypeNameExtractor(resolver, SimplePluginRegistry.create(plugins), new JacksonEnumTypeDeterminer()); plugin = new PageableParameterBuilderPlugin(extractor, resolver); }
Example #2
Source File: SwaggerManualApiPlugin.java From java-starthere with MIT License | 6 votes |
@Override public List<ApiDescription> apply(DocumentationContext documentationContext) { return new ArrayList<>(Arrays.asList(new ApiDescription(null, "/login", "login", Arrays.asList(new OperationBuilder(operationNames).authorizations(new ArrayList<>()) .summary("login") .codegenMethodNameStem("userLogin") .method(HttpMethod.POST) .notes("This is the login endpoint to request an authentication token") .responseMessages(responseMessages()) .parameters(Arrays.asList(new ParameterBuilder().description("Login Parameter") .type(new TypeResolver().resolve(UserLogin.class)) .name("userLogin") .parameterType("body") .parameterAccess("access") .required(true) .modelRef(new ModelRef("UserLogin")) .build())) .build()), false))); }
Example #3
Source File: SwaggerConfiguration.java From iotplatform with Apache License 2.0 | 6 votes |
@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())); }
Example #4
Source File: RequestToPoOperationBuilder.java From jframework with Apache License 2.0 | 6 votes |
private static Parameter genPrimaryTypeDoc(Field field, String prefix, String itemTypeName) { ApiModelProperty apiModelProperty = field.getAnnotation(ApiModelProperty.class); String description = ObjectUtils.isEmpty(apiModelProperty) ? field.getName() : apiModelProperty.value(); String name = CaseUtil.snakeCase(field.getName()); boolean required = false; NotNull notNull = field.getAnnotation(NotNull.class); if (notNull != null) { required = true; } return new ParameterBuilder() .description(description) .type(new TypeResolver().resolve(field.getClass())) .name(ObjectUtils.isEmpty(prefix) ? name : prefix + "." + name) .parameterType("query") .parameterAccess("access") .required(required) .modelRef(new ModelRef(itemTypeName)) .build(); }
Example #5
Source File: SwaggerConfiguration.java From halo with GNU General Public License v3.0 | 6 votes |
@Bean public AlternateTypeRuleConvention customizeConvention(TypeResolver resolver) { return new AlternateTypeRuleConvention() { @Override public int getOrder() { return Ordered.LOWEST_PRECEDENCE; } @Override public List<AlternateTypeRule> rules() { return Arrays.asList( newRule(User.class, emptyMixin(User.class)), newRule(UserDetail.class, emptyMixin(UserDetail.class)), newRule(resolver.resolve(Pageable.class), resolver.resolve(pageableMixin())), newRule(resolver.resolve(Sort.class), resolver.resolve(sortMixin()))); } }; }
Example #6
Source File: SwaggerConfiguration.java From Groza with Apache License 2.0 | 6 votes |
@Bean public Docket GrozaApi(){ 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("Groza") .apiInfo(apiInfo()) .alternateTypeRules( new AlternateTypeRule( jsonNodeType, stringType)) .select() .paths(apiPaths()) .build() .securitySchemes(newArrayList(jwtTokenKey())) .securityContexts(newArrayList(securityContext())); }
Example #7
Source File: WebApiApplictionInitalizer.java From summerframework with Apache License 2.0 | 6 votes |
@Override public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.getBeanFactory().addBeanPostProcessor(new InstantiationAwareBeanPostProcessorAdapter() { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof HandlerMethodResolver) { HandlerMethodResolver handlerMethodResolver = (HandlerMethodResolver)bean; Field typeResolverField = ReflectionUtils.findField(HandlerMethodResolver.class, "typeResolver", TypeResolver.class); ReflectionUtils.makeAccessible(typeResolverField); TypeResolver typeResolver = (TypeResolver)ReflectionUtils.getField(typeResolverField, handlerMethodResolver); return new HandlerMethodResolverWrapper(typeResolver); } else { return bean; } } }); }
Example #8
Source File: TypeContext.java From jsonschema-generator with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param annotationConfig annotation configuration to apply when collecting resolved fields and methods * @param derivingFieldsFromArgumentFreeMethods whether argument free methods should be represented as fields */ private TypeContext(AnnotationConfiguration annotationConfig, boolean derivingFieldsFromArgumentFreeMethods) { this.typeResolver = new TypeResolver(); this.memberResolver = new MemberResolver(this.typeResolver); this.annotationConfig = annotationConfig; this.derivingFieldsFromArgumentFreeMethods = derivingFieldsFromArgumentFreeMethods; }
Example #9
Source File: SwaggerPluginsAutoConfigurationTest.java From jhipster with Apache License 2.0 | 5 votes |
@Test public void testPageableParameterBuilderPlugin() { TypeResolver resolver = new TypeResolver(); List<TypeNameProviderPlugin> plugins = new LinkedList<>(); TypeNameExtractor extractor = new TypeNameExtractor(resolver, SimplePluginRegistry.create(plugins), new JacksonEnumTypeDeterminer()); PageableParameterBuilderPlugin plugin = pagePluginConfig.pageableParameterBuilderPlugin(extractor, resolver); assertThat(plugin.getResolver()).isEqualTo(resolver); assertThat(plugin.getNameExtractor()).isEqualTo(extractor); }
Example #10
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 5 votes |
public ModelCache addModel(ApiJsonObject jsonObj) { String modelName = jsonObj.name(); knownModels.put(modelName, new Model(modelName, modelName, new TypeResolver().resolve(String.class), "com.zsm.apidoc.apijson.util.CommonConst", toPropertyMap(jsonObj.value()), "POST参数", "", "", new ArrayList(), null, null )); String resultName = jsonObj.name() + "-" + "result"; knownModels.put(resultName, new Model(resultName, resultName, new TypeResolver().resolve(String.class), "com.zsm.apidoc.apijson.util.CommonConst", toResultMap(jsonObj.result(), resultName), "返回模型", "", "", new ArrayList(), null, null )); return ModelCacheSub.instance; }
Example #11
Source File: ParametersReader.java From Resource with GNU General Public License v3.0 | 5 votes |
@Autowired public ParametersReader(DescriptionResolver descriptions, TypeNameExtractor nameExtractor, TypeResolver resolver) { this.nameExtractor = nameExtractor; this.resolver = resolver; this.descriptions = descriptions; }
Example #12
Source File: SuccessPlugin.java From BlogManagePlatform with Apache License 2.0 | 5 votes |
public SuccessPlugin(TypeNameExtractor typeNameExtractor, TypeResolver typeResolver, SwaggerProperties properties) { this.typeNameExtractor = typeNameExtractor; this.typeResolver = typeResolver; this.useCustomerizedPluggins = properties.getUseCustomerizedPluggins(); okMessage = SwaggerUtil.statusDescription((item) -> { return item.getStatus() == HttpStatus.OK; }); ResponseMessageBuilder messageBuilder = new ResponseMessageBuilder(); messageBuilder.code(HttpStatus.OK.value()); messageBuilder.message(okMessage); messageBuilder.responseModel(new ModelRef(SwaggerModel.class.getSimpleName())); okResponses.add(messageBuilder.build()); okResult = typeResolver.resolve(SwaggerModel.class); }
Example #13
Source File: SwaggerConfig.java From BlogManagePlatform with Apache License 2.0 | 5 votes |
/** * 类型映射配置 * @author Frodez * @date 2019-12-04 */ private void typeConfig(Docket docket) { //将模型重定向 docket.directModelSubstitute(Result.class, SwaggerModel.class); docket.directModelSubstitute(LocalDate.class, String.class); docket.directModelSubstitute(LocalDateTime.class, String.class); docket.directModelSubstitute(LocalTime.class, String.class); TypeResolver resolver = new TypeResolver(); //有扫描包之外的模型,则在此配置 docket.additionalModels(resolver.resolve(QueryPage.class)); docket.additionalModels(resolver.resolve(PageData.class)); docket.additionalModels(resolver.resolve(SwaggerModel.class)); }
Example #14
Source File: SwaggerConfig.java From eladmin with Apache License 2.0 | 5 votes |
@Bean public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) { return new AlternateTypeRuleConvention() { @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } @Override public List<AlternateTypeRule> rules() { return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); } }; }
Example #15
Source File: SwaggerConfig.java From sk-admin with Apache License 2.0 | 5 votes |
@Bean public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) { return new AlternateTypeRuleConvention() { @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } @Override public List<AlternateTypeRule> rules() { return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); } }; }
Example #16
Source File: ApiRequestHandlerProvider.java From swagger-more with Apache License 2.0 | 5 votes |
@Autowired public ApiRequestHandlerProvider(List<ServiceBean> serviceBeans, HandlerMethodResolver methodResolver, TypeResolver typeResolver) { this.serviceBeans = serviceBeans; this.methodResolver = methodResolver; this.typeResolver = typeResolver; }
Example #17
Source File: HandlerMethodResolverWrapper.java From summerframework with Apache License 2.0 | 5 votes |
private static Function<ResolvedMethod, ResolvedType> toReturnType(final TypeResolver resolver) { return new Function<ResolvedMethod, ResolvedType>() { @Override public ResolvedType apply(ResolvedMethod input) { return Optional.fromNullable(input.getReturnType()).or(resolver.resolve(Void.TYPE)); } }; }
Example #18
Source File: SwaggerConfig.java From yshopmall with Apache License 2.0 | 5 votes |
@Bean public AlternateTypeRuleConvention pageableConvention(final TypeResolver resolver) { return new AlternateTypeRuleConvention() { @Override public int getOrder() { return Ordered.HIGHEST_PRECEDENCE; } @Override public List<AlternateTypeRule> rules() { return newArrayList(newRule(resolver.resolve(Pageable.class), resolver.resolve(Page.class))); } }; }
Example #19
Source File: PageableParameterBuilderPlugin.java From spring-cloud-gray with Apache License 2.0 | 4 votes |
public PageableParameterBuilderPlugin(TypeNameExtractor nameExtractor, TypeResolver resolver) { this.nameExtractor = nameExtractor; this.resolver = resolver; this.pageableType = resolver.resolve(Pageable.class); }
Example #20
Source File: PageableParameterBuilderPlugin.java From jhipster with Apache License 2.0 | 4 votes |
TypeResolver getResolver() { return resolver; }
Example #21
Source File: SwaggerPluginsAutoConfiguration.java From jhipster with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean public PageableParameterBuilderPlugin pageableParameterBuilderPlugin(TypeNameExtractor typeNameExtractor, TypeResolver typeResolver) { return new PageableParameterBuilderPlugin(typeNameExtractor, typeResolver); }
Example #22
Source File: ApiMethodModelsProvider.java From swagger-more with Apache License 2.0 | 4 votes |
@Autowired public ApiMethodModelsProvider(TypeResolver typeResolver) { this.typeResolver = typeResolver; }
Example #23
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 4 votes |
public Map<String, ModelProperty> toPropertyMap(ApiJsonProperty[] jsonProp) { // System.out.println("--- toPropertyMap ---"); Map<String, ModelProperty> propertyMap = new HashMap<String, ModelProperty>(); for (ApiJsonProperty property : jsonProp) { String propertyName = property.name(); ApiSingleParam param = paramMap.get(propertyName); String description = property.description(); if (isNullOrEmpty(description) && !isEmpty(param)) { description = param.value(); } String example = property.description(); if (isNullOrEmpty(example) && !isEmpty(param)) { example = param.example(); } Class<?> type = property.type(); if (!isEmpty(param)) { type = param.type(); } else if (isEmpty(type)) { type = String.class; } boolean allowMultiple = property.allowMultiple(); if (!isEmpty(param)) { allowMultiple = param.allowMultiple(); } ResolvedType resolvedType = null; if (allowMultiple) { resolvedType = new TypeResolver().resolve(List.class, type); } else { resolvedType = new TypeResolver().resolve(type); } // System.out.println("----- example: " + example); // System.out.println("----- description: " + description); ModelProperty mp = new ModelProperty( propertyName, resolvedType, type.toString(), 0, property.required(), false, property.readOnly(), null, description, null, example, null, property.defaultValue(), null, new ArrayList() );// new AllowableRangeValues("1", "2000"),//.allowableValues(new AllowableListValues(["ABC", "ONE", "TWO"], "string")) mp.updateModelRef(getModelRef()); propertyMap.put(property.name(), mp); } return propertyMap; }
Example #24
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 4 votes |
public Map<String, ModelProperty> transResultMap(List<String> values) { Map<String, ModelProperty> propertyMap = new HashMap<>(); for (String resultName : values) { ApiSingleParam param = paramMap.get(resultName); if (isEmpty(param)) { continue; } Class<?> type = param.type(); if (!isEmpty(param)) { type = param.type(); } else if (isEmpty(type)) { type = String.class; } boolean allowMultiple = param.allowMultiple(); if (!isEmpty(param)) { allowMultiple = param.allowMultiple(); } ResolvedType resolvedType = null; if (allowMultiple) { resolvedType = new TypeResolver().resolve(List.class, type); } else { resolvedType = new TypeResolver().resolve(type); } ModelProperty mp = new ModelProperty( resultName, resolvedType, param.type().getName(), 0, false, false, true, false, param.value(), null, param.example(), null, "", null, new ArrayList() );// new AllowableRangeValues("1", "2000"),//.allowableValues(new AllowableListValues(["ABC", "ONE", "TWO"], "string")) mp.updateModelRef(getModelRef()); propertyMap.put(resultName, mp); } return propertyMap; }
Example #25
Source File: SpringfoxSupportConfiguration.java From swagger-more with Apache License 2.0 | 4 votes |
@Bean public HandlerMethodResolver methodResolver(TypeResolver resolver) { return new HandlerMethodResolver(resolver); }
Example #26
Source File: ResponseMessageReader.java From Resource with GNU General Public License v3.0 | 4 votes |
public ResponseMessageReader(TypeNameExtractor typeNameExtractor, TypeResolver typeResolver) { super(typeNameExtractor, typeResolver); this.typeNameExtractor = typeNameExtractor; this.typeResolver = typeResolver; }
Example #27
Source File: SpringfoxSupportConfiguration.java From swagger-more with Apache License 2.0 | 4 votes |
@Bean public TypeResolver typeResolver() { return new TypeResolver(); }
Example #28
Source File: ClassmateContext.java From lams with GNU General Public License v2.0 | 4 votes |
public TypeResolver getTypeResolver() { if ( typeResolver == null ) { throw new IllegalStateException( "Classmate context has been released" ); } return typeResolver; }
Example #29
Source File: PageableParameterBuilderPlugin.java From albedo with GNU Lesser General Public License v3.0 | 4 votes |
TypeResolver getResolver() { return resolver; }
Example #30
Source File: PageableParameterBuilderPlugin.java From albedo with GNU Lesser General Public License v3.0 | 4 votes |
@Autowired public PageableParameterBuilderPlugin(TypeNameExtractor nameExtractor, TypeResolver resolver) { this.nameExtractor = nameExtractor; this.resolver = resolver; this.pageableType = resolver.resolve(Page.class); }