Skip to content

Conversation

@Kwok-he-Chu
Copy link
Member

This is a POC to see what the generated classes look like Do NOT merge this branch

Description

This allows developers to only see the member variables that don't start with underscore
Update mustache template to ConstructHostUrl in HostConfiguration
Modified mustache template to do required-fields check before JsonSerializer.Read(..)
Updated mocks to use latest OpenAPI specs data & new ids
…izations

Removed old enums and copied the mustache template from my local branch to support generation of these stringEnum : IEnum
./gradlew :dotnet:services -PopenapiGeneratorVersion=7.16.0
@Kwok-he-Chu Kwok-he-Chu self-assigned this Oct 28, 2025
@Kwok-he-Chu Kwok-he-Chu requested review from a team as code owners October 28, 2025 16:27
@gemini-code-assist
Copy link

Summary of Changes

Hello @Kwok-he-Chu, 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 upgrades the Adyen .NET generator to support the latest OpenApiGenerator, incorporates several new features including support for anyOf/allOf APIs, upgrades to System.Text.Json, adds core functionalities, and introduces forward compatible enums. It also refactors the client class naming and updates target frameworks, along with adding new integration tests and support for AcsWebhooks, Balance Control, Balance Platform, and BinLookup.

Highlights

  • Adyen .NET Generator Upgrade: The Adyen .NET generator has been upgraded to support the latest OpenApiGenerator, enhancing its capabilities and compatibility.
  • Support for anyOf, allOf APIs: The generator now supports anyOf and allOf API specifications, allowing for more complex data models.
  • Upgrade to System.Text.Json: The generator has been upgraded to use System.Text.Json for serialization and deserialization, providing performance and security benefits.
  • Additional Core Functionalities: New core functionalities have been added to the generator, improving its overall utility and flexibility.
  • Forward Compatible Enums: Forward compatible enums have been added, using classes as Strings rather than enum values, addressing issue Discussion: Should we make the enums forward-compatible? #1071.
  • Target Framework Update: The target framework for integration tests and tests has been updated to .NET 8.0, removing support for older frameworks.
  • Client Class Refactoring: The Client class has been renamed to AdyenClient across multiple test files, improving clarity and consistency.
  • New Integration Tests: Added new integration tests for the Checkout API, specifically focusing on payments service functionality.
  • AcsWebhooks Support: Added support for AcsWebhooks, including deserialization and testing capabilities.
  • Balance Control and Balance Platform Support: Added support for Balance Control and Balance Platform, including deserialization and testing capabilities.
  • BinLookup Support: Added support for BinLookup, including deserialization and testing capabilities.
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

@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 is a proof-of-concept for upgrading the .NET generator, which introduces significant changes and new patterns. The upgrade to System.Text.Json and the introduction of a dependency injection-based client setup are great steps forward. My review focuses on improving maintainability and robustness of the newly generated code. I've identified a few areas for improvement:

  • The new generator produces test methods marked as async Task that don't use await.
  • There's inconsistent use of fully qualified type names versus using aliases, which affects readability.
  • Some of the generated utility methods could be more efficient and robust.
    I've left specific comments with suggestions on these points. Overall, this is a promising direction for the generator.

_jsonOptions.Converters.Add(new EntryModesRestrictionJsonConverter());
_jsonOptions.Converters.Add(new ExpiryJsonConverter());
_jsonOptions.Converters.Add(new FeeJsonConverter());
_jsonOptions.Converters.Add(new FinishScaDeviceRegistrationRequestJsonConverter());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The ConstructLiveUrl method relies on string matching and replacement to build the live endpoint URL. This approach is brittle and can easily break if the base URL format changes. For example, it checks for pal- or checkout- in the URL. A more robust solution would be to define the URL templates for test and live environments separately and populate them with parameters like liveEndpointUrlPrefix, rather than using string manipulation. This would make the URL construction more reliable and easier to maintain.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we are already aware of, we should have these URLs as part of our open-api-specs and somehow populate them during the generation @gcatanese

/// <param name="obj">The parameter (header, path, query, form).</param>
/// <param name="format">The DateTime serialization format.</param>
/// <returns>Formatted string.</returns>
public static string? ParameterToString(object? obj, string? format = ISO8601_DATETIME_FORMAT)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The ParameterToString method uses a long chain of if statements to handle enum serialization. This can be inefficient and hard to maintain as the number of enums grows. Consider using a more scalable approach, such as a dictionary mapping types to serialization functions, or a different design pattern for dispatching based on type. Since this is generated code, this might require a change in the generator template.

@Kwok-he-Chu
Copy link
Member Author

Closed this PR

@Kwok-he-Chu Kwok-he-Chu closed this Nov 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discussion: Should we make the enums forward-compatible?

2 participants