-
-
Notifications
You must be signed in to change notification settings - Fork 179
Type Introspection: non-nullable field with default is reported as required #609
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
Comments
@pepperbob - val beandescription = mapper.getSerializationConfig().introspect(javaType)
+ val beandescription = mapper.deserializationConfig.introspect(javaType) Can you please confirm if the problem occurs again after using this? |
@k163377 would that change the original issue wrt preference of introspected information? It is also worth noting that calls to |
@k163377 Quickly tried this and introspection via KotlinAnnotationIntrospector#requiredAnnotationOrNullability applies still the same rules but the path |
@k163377 Sorry, I have to correct myself as this is wrong:
In my example the So after some tests I think that As I understood this cannot work for |
I thought this was a deliberate override of priorities. The |
@pepperbob
Does this mean that you want |
@k163377 Ah yes, the defaulting of |
@k163377 Considering the subtle differences between serialization/de-serialization everything works as expected and it's not a bug after all. Thank you for your time bringing this to my attention - #397 already had the answer somewhere but I didn't undertstand. So as a conclusion:
So "required" has this further dimension that needs to be considered when building things upon it. |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Type-Introspection of a data class reports its property as "required" though it has a default value. The reason - at least in my case - is that KotlinAnnotationIntrospector#requiredAnnotationOrNullability favors "required by nullability" over whatever the
JsonProperty
annotation says.To Reproduce
Expected behavior
It would be nice if the introspection could consider the propertys' default-value; however I would expect to overrule its decisions by being explicit via the
JsonProperty
-Annotation.Versions
Kotlin: 1.7.0
Jackson-module-kotlin: 2.13.4
Jackson-databind: 2.13.4.2
Additional context
Frameworks that are using Jacksons introspection on Kotlin classes will come to wrong conclusions (as seen in swagger.io which produces kind of wrong schemas). Something similiar has been reported in issue #397
The text was updated successfully, but these errors were encountered: