Skip to content

Conversation

@gcatanese
Copy link
Contributor

@gcatanese gcatanese commented Dec 4, 2025

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: null attributes are not included in the JSON requests. However, developers can override the logic by customizing the request object:

  • set includeNullValues as true
  • set explicitly the attribute(s) as null
TerminalSettings terminalSettings = new TerminalSettings();
    terminalSettings
        .includeNullValues(true)
        .connectivity(new Connectivity().simcardStatus(Connectivity.SimcardStatusEnum.ACTIVATED))
        .setSurcharge(null);

The 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 true when 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:

  • AffirmInfo add pricePlan attribute
  • PaymentMethod add support for Givex, Scs, Valuelink
  • PaymentMethodResponse add support for Klarna_b2b, Givex, Scs, Valuelink
  • PaymentMethodSetupInfo add support for Klarna_b2b, Givex, Scs, Valuelink
  • TerminalSettings add support for Moto
  • UpdatePaymentMethodInfo deprecate storeIds attribute

Fix #1584

@gcatanese gcatanese requested review from a team as code owners December 4, 2025 16:35
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @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, null attributes were omitted from JSON requests by default. With this change, clients can now explicitly include null values in their JSON payloads by setting an includeNullValues flag and explicitly setting attributes to null. This functionality is particularly beneficial for scenarios involving partial updates or PATCH requests, ensuring greater control and consistency with various API contract requirements.

Highlights

  • Explicit Null Serialization: Introduced support for explicit null serialization in all model classes, allowing clients to control whether attributes with null values are included in JSON payloads.
  • New Flags and Helper Methods: Added isSet boolean flags for each property to track if an attribute has been explicitly set, along with an includeNullValues flag and a getExplicitNulls() method utilizing @JsonAnyGetter for conditional null serialization.
  • API Flexibility: This enhancement improves API flexibility and consistency, particularly for handling partial updates and PATCH requests, by giving developers fine-grained control over null value inclusion.
  • Model Simplification: The DeviceInfo.java model was refactored to remove several fields, streamlining its structure and focusing on core device information.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@gcatanese gcatanese force-pushed the handle-nullable-properties branch from 7bec7c5 to 7ca7926 Compare December 5, 2025 09:56
@gcatanese gcatanese requested a review from galesky-a December 5, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Indicates new feature requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Nulling out or resetting surcharge configurations for terminal settings does not work

3 participants