-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[Java] Add a new additional property to configure Jackson's failOnUnknownProperties
#19271
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
Changes from all commits
6f8f318
1cf8590
38a15fb
a20b4bf
36f76f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,7 @@ public class JSON implements ContextResolver<ObjectMapper> { | |
| mapper = JsonMapper.builder() | ||
| .serializationInclusion(JsonInclude.Include.NON_NULL) | ||
| .configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false) | ||
| .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true) | ||
| .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, {{failOnUnknownProperties}}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, could you please make this change for other libraries besides retrofit2 as well?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, yes, I can do this, the only issue is that some libraries are configured to fail on unknown properties, some aren't. I see that Is there an elegant way to tell JavaClientCodegen to default the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. My preferred approach would be to use this opportunity to unify the behaviour of the different libraries. Since the majority uses
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's done!
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! Some tests in failOnUnknownProperties: true
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed! Thanks for the hint, I had trouble finding where it came from |
||
| .configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true) | ||
| .disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS) | ||
| .enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING) | ||
|
|
||
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.
are there plans to have something similar for Kotlin generators too? I got exactly the same issue using Kotlin + okhttp3 client and seems like there we use the same properties and in Java's generators.
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 can probably take a look once this PR is merged. Is there a issue already?
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.
thanks a lot. I am not aware of formal issue yet but please let me know if I should open one.
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.
Yes, that would be great!
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.
here it is #19408 . Thanks!