Support distinct jsonviews for serialization and deserialization #46807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before, the jsonview for the request body could leak affect the serialization side, and cause the response entity to be written with the wrong jsonview. Now, the method and class level jsonview affect the serialization side, while a method parameter jsonview affect only the deserialization side.
However, technically speaking, this is also a minor breaking change for undocumented behaviour. Should be worth it though, since this implementation is less surprising, and follows what is currently documented at https://quarkus.io/version/main/guides/rest#jsonview-support.
Therefore, a note for the migration guide:
closes #46751
Quarkus Rest - JsonView Deserialization changes
With this version, the deserialization support for jsonviews gets documented and slightly changed.
For example:
(1) The method parameter
user
was also deserialized using theViews.Private
view.(2) The method parameter
user
was most likely to correctly use the expectedViews.Public
view for deserialization. For Serialization however, theViews.Public
was also used, although the method is annoted with theViews.Private
view.The behaviour changed, so that now the deserialization is only influenced by the method parameter jsonview. The serialization is now always only influenced by the method (or class level) jsonview.
For (1), the
user
parameter does not use any JsonView anymore.For (2), this means that the
user
parameter correctly uses Views.Public for deserialization, and for serialization Views.Private gets used