Skip to content

Conversation

@Kwok-he-Chu
Copy link
Member

@Kwok-he-Chu Kwok-he-Chu commented Nov 26, 2025

PR-4 of #1204

Description

This PR adds the tests needed for the generation of the new models and services using the new OpenApiGenerator to v7.16.0 used in the Adyen sdk-automation to generate .NET models & services from the Adyen OpenAPI Specifications.

This won't compile until we run the sdk-automation (see PR) with our new templates.

Remove old mustache templates
Removed old /Adyen/Model using the previous models/services
Removed old /Adyen/Service using the previous models/services
Removed old /Adyen/Service.Test using the previous models/services
Removed old /IntegrationTests using the previous models/services
@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 is a crucial step in upgrading the OpenAPI Generator to version 7.16.0, which is essential for maintaining up-to-date and robust .NET models and services. The core of this PR involves a complete refactoring of the integration test suite, moving from an outdated structure to a modern, maintainable setup that fully supports the new generator's output and a more logical library organization. This ensures that all newly generated components are thoroughly validated and seamlessly integrated into the SDK.

Highlights

  • OpenAPIGenerator Upgrade: The OpenAPIGenerator has been upgraded to version 7.16.0, which is a significant update for generating .NET models and services.
  • Comprehensive Test Coverage: All services and models now have dedicated tests, ensuring the reliability and correctness of the generated code.
  • New Library Structure Adoption: The generated models and services now follow a new, more organized library structure, with API-specific models and services grouped under /Adyen/ApiName/Models and /Adyen/ApiName/Services respectively.
  • Refactored Integration Tests: Old integration test files have been removed and replaced with new ones that align with the updated generator's output and leverage modern .NET features like dependency injection.
  • Target Framework Update: The project files (csproj) have been updated to target net8.0 exclusively, streamlining the build process and focusing on the latest .NET long-term support version.
Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/build-net6.0.yml
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 introduces a significant and positive modernization of the Adyen .NET library. The upgrade of the OpenAPI generator, the addition of a comprehensive suite of new tests, and the architectural shift towards Microsoft.Extensions.DependencyInjection, IHttpClientFactory, and System.Text.Json are excellent improvements. The refactoring also includes better code organization, such as the new Core project and the restructuring of the test projects.

However, there are a few critical points to address. The most significant is the change in target frameworks, which drops support for .NET 6, .NET Framework, and .NET Standard, making this a major breaking change that should be clearly communicated. I've also identified a minor bug in logging arguments and some areas for code cleanup, such as fragile URL construction logic and commented-out test files that should be removed.

Overall, this is a substantial step forward for the library. Addressing the identified issues will ensure a smoother transition for users and improve the long-term maintainability of the codebase.


<PropertyGroup>
<TargetFrameworks>net8.0;net6.0;net462;netstandard2.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>

Choose a reason for hiding this comment

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

critical

The change from <TargetFrameworks>net8.0;net6.0;net462;netstandard2.0</TargetFrameworks> to <TargetFramework>net8.0</TargetFramework> is a significant breaking change. It drops support for .NET 6, .NET Framework 4.6.2, and .NET Standard 2.0, making the library compatible only with .NET 8. This should be clearly communicated in the pull request description and release notes. If this is not the intended outcome, the previous target frameworks should be restored.

events.OnPayments += (sender, eventArgs) =>
{
ApiResponse apiResponse = eventArgs.ApiResponse;
logger.LogInformation("{TotalSeconds,-9} | {Path} | {StatusCode} |", (apiResponse.DownloadedAt - apiResponse.RequestedAt).TotalSeconds, apiResponse.StatusCode, apiResponse.Path);

Choose a reason for hiding this comment

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

medium

The arguments for the structured log message are in the wrong order. The format string is "{TotalSeconds,-9} | {Path} | {StatusCode} |", but the arguments are provided as TotalSeconds, apiResponse.StatusCode, and apiResponse.Path. This will cause the status code to be logged as the path and vice versa. The arguments should be swapped to match the format string.

                logger.LogInformation("{TotalSeconds,-9} | {Path} | {StatusCode} |", (apiResponse.DownloadedAt - apiResponse.RequestedAt).TotalSeconds, apiResponse.Path, apiResponse.StatusCode);

@@ -0,0 +1,504 @@
// using System;

Choose a reason for hiding this comment

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

medium

This entire test file is commented out. If these tests are not planned to be implemented as part of this pull request, the file should be removed to avoid cluttering the codebase with dead code. If they are planned for a future PR, a TODO comment explaining this would be helpful.

@@ -0,0 +1,124 @@
// using System;

Choose a reason for hiding this comment

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

medium

This entire test file is commented out. Similar to BalancePlatformWebhookHandlerTest.cs, this file should either be removed to avoid cluttering the codebase, or a TODO comment should be added to clarify its status if it's intended for future work.

Comment on lines +38 to +79
public static string ConstructLiveUrl(string liveEndpointUrlPrefix, string url)
{
// Change base url for Live environment
if (url.Contains("pal-")) // Payment API prefix
{
if (liveEndpointUrlPrefix == null)
{
throw new InvalidOperationException("LiveEndpointUrlPrefix is null - please configure your AdyenOptions.LiveEndpointUrlPrefix");
}

url = url.Replace("https://pal-test.adyen.com/pal/servlet/",
"https://" + liveEndpointUrlPrefix + "-pal-live.adyenpayments.com/pal/servlet/");
}
else if (url.Contains("checkout-")) // Checkout API prefix
{
if (liveEndpointUrlPrefix == null)
{
throw new InvalidOperationException("LiveEndpointUrlPrefix is null - please configure your AdyenOptions.LiveEndpointUrlPrefix");
}

if (url.Contains("possdk"))
{
url = url.Replace("https://checkout-test.adyen.com/",
"https://" + liveEndpointUrlPrefix + "-checkout-live.adyenpayments.com/");
}
else
{
url = url.Replace("https://checkout-test.adyen.com/",
"https://" + liveEndpointUrlPrefix + "-checkout-live.adyenpayments.com/checkout/");
}
}
else if (url.Contains("https://test.adyen.com/authe/api/")) // SessionAuthentication
{
url = url.Replace("https://test.adyen.com/authe/api/",
"https://authe-live.adyen.com/authe/api/");
}

// If no prefix is required, we replace "test" -> "live"
url = url.Replace("-test", "-live");
return url;
}
}

Choose a reason for hiding this comment

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

medium

The logic in this method for constructing live URLs is complex and relies on string manipulation (Contains, Replace), which can be fragile and error-prone. For example, the final url.Replace("-test", "-live") is broad and could have unintended side effects if "-test" appears elsewhere in the URL. The repeated null check for liveEndpointUrlPrefix can also be simplified. Consider refactoring this to use a more structured approach, perhaps using a dictionary or a configuration object to map test URLs to live URLs for different services, to improve maintainability and reduce the risk of errors.

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.

2 participants