-
Notifications
You must be signed in to change notification settings - Fork 123
[Do not merge] Upgraded Adyen's .NET generator to support latest OpenApiGenerator #1203
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
Add extensions Fix templates (wrong copy)
Fix Namespaces for System.Net.Http
Remove method DefaultOrAsync on interface-level
Rename IApi to IAdyenApiService to match /services folder
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(..)
Reason: Useless information
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
Summary of ChangesHello @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 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 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 Taskthat don't useawait. - There's inconsistent use of fully qualified type names versus
usingaliases, 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()); |
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.
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.
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.
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) |
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.
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.
|
Closed this PR |
This is a POC to see what the generated classes look like Do NOT merge this branch
Description
System.Text.Json