-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Feature/Support for QueryValue as a object #11787
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 4.9.x
Are you sure you want to change the base?
Feature/Support for QueryValue as a object #11787
Conversation
@dstepanov can you think of a better way to do this? otherwise i think it's ok |
BeanIntrospection<T> introspection = introspectionOpt.get(); | ||
T instance; | ||
try { | ||
instance = introspection.instantiate(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why no-args constructor is required? I'think you need more tests with record
and required args constructor (without no-arg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update!
return BindingResult.unsatisfied(); | ||
} | ||
|
||
BeanIntrospection<T> introspection = introspectionOpt.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be altered to use introspection.builder()
so that records, immutable types, types with custom constructors etc. are supported.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using IntrospectionBuilder
API and finally call the build()
method any exception should b caught and the conversion rejected with context.reject
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the changes with the introspection.builder(). Seems to work for object with custom constructor but I made a test for record and don't work. Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is because records are not supported in Groovy and you a rewriting the test in Groovy. Probably will be fixed by #11832
…s, types with custom constructors etc.
http/src/main/java/io/micronaut/http/bind/binders/QueryValueArgumentBinder.java
Show resolved
Hide resolved
BeanIntrospection<T> introspection = introspectionOpt.get(); | ||
BeanIntrospection.Builder<T> introspectionBuilder = introspection.builder(); | ||
|
||
for (BeanProperty<T, Object> property : introspection.getBeanProperties()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
iterative here over the getBuilderArguments() using array iteration to obtain the index
http/src/main/java/io/micronaut/http/bind/binders/QueryValueArgumentBinder.java
Outdated
Show resolved
Hide resolved
http/src/main/java/io/micronaut/http/bind/binders/QueryValueArgumentBinder.java
Outdated
Show resolved
Hide resolved
Optional<Object> converted = conversionService.convert(value.get(), context.with(property.asArgument())); | ||
if (converted.isPresent()) { | ||
try { | ||
introspectionBuilder.with(propertyName, converted.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
invoke with passing the index from the array iteration https://docs.micronaut.io/latest/api/io/micronaut/core/beans/BeanIntrospection.Builder.html#with(int,io.micronaut.core.type.Argument,A)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with getBuilderArguments() iteration, still not working for the records
import io.micronaut.core.annotation.Introspected; | ||
|
||
@Introspected | ||
public record PaginationRequest(Integer page, Integer size) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarianConstantinMarica just rename PaginationRequest.java
to PaginationRequest.groovy
and after this all must work correctly
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
# Conflicts: # gradle.properties # inject-java/src/test/resources/META-INF/services/io.micronaut.inject.visitor.TypeElementVisitor
….10.x-upd Merge 4.9.x
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ronaut-projects#11880) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…icronaut-projects#11896) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…-projects#11899) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
# Conflicts: # gradle.properties
….10.x-merge 4.9.x->4.10.x merge
…ec to better reflect its actual contents. (micronaut-projects#11874) The default order of an object in OrderUtil.getOrder should be zero not LOWEST_PRECEDENCE, as otherwise there is no way to request a bean be last in the list. The intention here is to leave a bean that doesn't request an order un-ordered relative to other beans, so zero is the correct value. Apply a global ordering to all bean event listeners regardless of requested generic type. Previously, listeners were ordered only relative to other listeners that specified the same generic type, meaning the final ordering could be unexpected in cases where supertypes were matched. Ordering is now done after all the listeners are aggregated.
…ronaut-projects#11909) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…180 (micronaut-projects#11903) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…cronaut-projects#11922) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…11927) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…ects#11774) For motivation and rationale see micronaut-projects#11655
… to v1.6.16 (micronaut-projects#11940) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Used for future PEM loading PR.
…ects#11934) * Add new OutputStream buffer method to ByteBodyFactory This will be useful for micronaut-jax-rs optimizations. * CR
…11945) * fix(deps): update netty monorepo to v4.2.3.final * remove obsolete deletions * build time init --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: yawkat <jonas.konrad@oracle.com>
) This PR adds support for loading PEM files in place of key and trust stores. - Introduce a PemParser class that can load various PEM types: PKCS#8 private keys (possibly encrypted), PKCS#1 private keys, SEC.1 elliptic curve keys, X.509 certificates. This is a bit complicated because we need to do some content sniffing. - If key store loading fails from a path, also try loading it as PEM. For key stores, the expected format is a single PRIVATE KEY followed by some CERTIFICATEs, while for a trust store it expects a set of CERTIFICATEs. - Add properties to KeyStoreConfiguration for separate key and certificate files, since keeping them separate is more common in practice (incl. in the docs) - Update docs
…181 (micronaut-projects#11953) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…icronaut-projects#11946) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…-projects#11959) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
No description provided.