Skip to content
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

Added support for the 'required' attribute for the generated JSON Property Annotation #1515

Conversation

harrismirza
Copy link

@harrismirza harrismirza commented May 14, 2024

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.

@elucash
Copy link
Member

elucash commented May 21, 2024

Thank you for the PR! This is good solution, merging

@elucash elucash merged commit 4c737f7 into immutables:master May 21, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants