Added support for the 'required' attribute for the generated JSON Property Annotation #1515
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.
Hi,
Raising this PR to solve this issue raised a while back: #924.
Essentially when we generate a Value class, we are adding an 'JsonProperty' annotation, but this does not have the 'required=true' flag set for non-nullable fields.
This is useful when inspecting the classes for things like generating API specs and JSON Schemas.
I have set this to be controlled by a style flag, so users can disable this functionality if needed.
As seen in the docs (https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-annotations/latest/com/fasterxml/jackson/annotation/JsonProperty.html#required--), this should not actually affect deserialization behaviour for most users of Immutables, as they would be using the builder for deserialisation.