-
Notifications
You must be signed in to change notification settings - Fork 145
Skip Handling of Nullable Properties in Webhooks #1609
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 introduces a targeted optimization to the code generation process, specifically for Java models. It ensures that boilerplate code for handling nullable properties is only generated when necessary, primarily for API models, thereby streamlining webhook-related classes and improving overall code efficiency and clarity. 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 for handling explicit null serialization in the generated model classes. This is done by adding isSet... flags for each property and using a custom serialization logic with @JsonAnyGetter. The changes are conditionally applied based on a handleNullableProperties flag in the Mustache template.
While the overall approach is sound, I've found a significant issue: the equals() and hashCode() methods in the generated classes are not updated to account for the new isSet... flags. This breaks the equals contract, as objects that are considered equal can produce different JSON representations. I've left comments on how to address this in both the template and one of the generated classes. This issue is critical for ensuring the correctness of collections and other logic that relies on object equality.
This PR adjust the approach implemented in #1603, by skipping the generation of the code that handles the
nullableproperties in case of Webhook classes (as there is no need to handle nullable attributes).The Mustache templates have been updated to check if the additionalData
handleNullablePropertiesis set by the SDK Automation Bot (see PR). The flag is only set for models that belong to an API.In a second commit I have corrected the implementation of
hashCodeandequals, to include the new attributes that the generation now includes.This PR also generates the
RecurringAPI models.