-
Notifications
You must be signed in to change notification settings - Fork 145
Handle nullable properties #1603
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
Conversation
Summary of ChangesHello @gcatanese, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the API's flexibility by introducing explicit null serialization across all model classes. Previously, Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces a mechanism to explicitly serialize null values in model classes, which provides more control over the generated JSON payload. The implementation adds includeNullValues and isSet<Property> flags to track state, along with a @JsonAnyGetter method getExplicitNulls to handle the serialization.
While the approach is functional, I've identified significant code duplication, particularly with the addIfNull helper method and the boilerplate for includeNullValues handling, which are repeated in every modified model. I've left a comment suggesting the use of a base class or utility class to centralize this logic, which would greatly improve maintainability.
Additionally, I've suggested an alternative to using individual isSet<Property> boolean flags by using a single Set<String> to track set properties, which would reduce the number of fields and simplify the models.
Finally, I've flagged a potentially breaking change in the DeviceInfo class where several fields have been removed. This should be reviewed to ensure it is intentional.
Overall, the changes achieve the goal of handling nullable properties, but there are opportunities to refactor for better code quality and long-term maintenance.
7bec7c5 to
7ca7926
Compare
This pull request adds support for explicit null serialization in the Management API classes, allowing clients to control whether attributes with null values are included in the JSON payload.
The default behavior doesn't change:
nullattributes are not included in the JSON requests. However, developers can override the logic by customizing the request object:includeNullValuesastruenullThe changes introduce new flags and helper methods to track when attributes are explicitly set to null. This is done by introducing a state (boolean flag) that it is marked as
truewhen the attribute is modified.Attributes initialised as null are not considered updated and it will not included in the serialization.
This improves API flexibility and consistency, especially for partial updates or PATCH requests.
These changes ensure that API consumers have fine-grained control over the inclusion of null values in their requests, which is important for partial updates (i.e. update
TerminalSettings) and for conforming to various API contract requirements.Other changes
The Management API models have been regenerated to implement the new Mustache templates, meanwhile the Management API OpenAPI spec has changed, therefore there are other changes:
AffirmInfoaddpricePlanattributePaymentMethodadd support forGivex,Scs,ValuelinkPaymentMethodResponseadd support forKlarna_b2b,Givex,Scs,ValuelinkPaymentMethodSetupInfoadd support forKlarna_b2b,Givex,Scs,ValuelinkTerminalSettingsadd support forMotoUpdatePaymentMethodInfodeprecatestoreIdsattributeFix #1584