Skip to content

WIP Typescript OpenAPI Generator v7 #1505

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

Merged
merged 39 commits into from
Jun 10, 2025
Merged

Conversation

gcatanese
Copy link
Contributor

@gcatanese gcatanese commented Jun 2, 2025

Refactor to use OpenAPI Generator v7:

  • update Mustache templates to preserve backward compatibility
  • generate Checkout, Payout, Recurring, BinLookUp, DataProtection, PosMobile, PaymentsApp, DataProtection
  • add SessionAuthentication to support allOf
  • Similar to the Java library the "small" services are moved to their own folder
  • code format: use " instead of '

@gcatanese gcatanese requested a review from a team as a code owner June 2, 2025 07:48
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.

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!

Summary of Changes

This pull request focuses on refactoring the Typescript OpenAPI Generator to version 7. It includes updates to Mustache templates, generation of new service APIs (Checkout, Payout, Recurring, BinLookUp, DataProtection, PosMobile, PaymentsApp, SessionAuthentication), and code formatting changes to use double quotes instead of single quotes. The PR also includes updates to eslint configuration and associated tests.

Highlights

  • OpenAPI Generator v7 Refactor: The core intent is to upgrade the Typescript OpenAPI Generator to version 7, bringing in new features and improvements from the generator.
  • New Service API Generation: This PR generates service APIs for Checkout, Payout, Recurring, BinLookUp, DataProtection, PosMobile, PaymentsApp, and SessionAuthentication, expanding the library's capabilities.
  • Template Updates: Mustache templates have been updated to align with OpenAPI Generator v7's requirements.
  • Code Formatting: The code has been formatted to consistently use double quotes (") instead of single quotes ('), improving code style.
  • Eslint Configuration: Eslint configuration has been updated to exclude src/typings/**/*.ts from default rules, and only apply unused-imports rule.
  • SessionAuthentication API: Adds SessionAuthentication API to support allOf.

Changelog

Click here to see the changelog
  • .eslintignore
    • Removes exclusion of /src/typings/**/*.ts.
  • .eslintrc.js
    • Modifies eslint overrides to apply unused-imports/no-unused-imports rule only to src/typings/**/*.ts files.
    • Adds a default rule set for all .ts files except those in src/typings/**/*.ts.
  • src/mocks/checkout/payments3DS2NativeAction.ts
    • Adds a mock for payments3DS2NativeAction to simulate a 3DS2 Native action.
  • src/mocks/checkout/paymentsRedirectAction.ts
    • Adds a mock for paymentsRedirectAction to simulate a shopper redirect action.
  • src/tests/binLookup.spec.ts
    • Updates imports to use BinLookupAPI from ../services instead of ../services/binLookupApi.
    • Updates tests to call BinLookupApi.get3dsAvailability and BinLookupApi.getCostEstimate instead of calling the methods directly on the binLookupService.
  • src/tests/checkout.spec.ts
    • Adds imports for paymentsRedirectAction and payments3DS2NativeAction mocks.
    • Adds tests to check for shopper redirect and Native 3DS2 with card payments.
    • Updates ObjectSerializer.deserialize calls to include an empty string as the third argument.
  • src/tests/dataProtection.spec.ts
    • Updates tests to call DataProtectionApi.requestSubjectErasure instead of calling the method directly on the dataProtectionService.
  • src/tests/httpClient.spec.ts
    • Updates tests to call BinLookupApi.get3dsAvailability instead of calling the method directly on the binLookup or binLookupService.
  • src/tests/paymentsAppApi.spec.ts
    • Creates a new test suite for PaymentsAppApi to test boarding token generation and payments app listing/revoking.
  • src/tests/posMobileApi.spec.ts
    • Creates a new test suite for PosMobileApi to test communication session creation.
  • src/tests/recurring.spec.ts
    • Updates imports to use RecurringAPI from ../services instead of ../services/recurringApi.
    • Updates tests to call RecurringApi.listRecurringDetails, RecurringApi.disable, RecurringApi.notifyShopper, RecurringApi.scheduleAccountUpdater, RecurringApi.createPermit, and RecurringApi.disablePermit instead of calling the methods directly on the recurringService.
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/tests/sessionAuthenticationApi.spec.ts
    • Creates a new test suite for SessionAuthenticationApi to test authentication session creation.
  • src/service.ts
    • Updates the condition to check for /possdk/v68 using double quotes instead of single quotes.
  • src/services/binLookup/binLookupApi.ts
    • Creates a new BinLookupApi class with methods for get3dsAvailability and getCostEstimate.
  • src/services/binLookup/index.ts
    • Creates a new BinLookupAPI class that exports the BinLookupApi.
  • src/services/binLookupApi.ts
    • Adds deprecation notice to the BinLookupAPI class.
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
    • Adds deprecation notice to the get3dsAvailability and getCostEstimate methods.
  • src/services/checkout/donationsApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/checkout/modificationsApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/checkout/ordersApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/checkout/paymentLinksApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/checkout/paymentsApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/checkout/recurringApi.ts
    • Creates a new RecurringApi class with methods for recurring payments.
  • src/services/checkout/utilityApi.ts
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
  • src/services/dataProtection/dataProtectionApi.ts
    • Creates a new DataProtectionApi class with methods for data protection requests.
  • src/services/dataProtection/index.ts
    • Creates a new DataProtectionAPI class that exports the DataProtectionApi.
  • src/services/dataProtectionApi.ts
    • Adds deprecation notice to the DataProtectionAPI class.
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
    • Adds deprecation notice to the requestSubjectErasure method.
  • src/services/index.ts
    • Updates the barrel file to export the new services and remove the deprecated ones.
  • src/services/paymentsApp/paymentsAppApi.ts
    • Creates a new PaymentsAppApi class with methods for payments app management.
  • src/services/posMobile/index.ts
    • Creates a new PosMobileAPI class that exports the PosMobileApi.
  • src/services/posMobile/posMobileApi.ts
    • Creates a new PosMobileApi class with methods for POS mobile communication.
  • src/services/posMobileApi.ts
    • Adds deprecation notice to the PosMobileAPI class.
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
    • Adds deprecation notice to the createCommunicationSession method.
  • src/services/recurring/index.ts
    • Creates a new RecurringAPI class that exports the RecurringApi.
  • src/services/recurring/recurringApi.ts
    • Creates a new RecurringApi class with methods for recurring payments.
  • src/services/recurringApi.ts
    • Adds deprecation notice to the RecurringAPI class.
    • Updates ObjectSerializer.serialize calls to include an empty string as the third argument.
    • Adds deprecation notice to the createPermit, disable, disablePermit, listRecurringDetails, notifyShopper, and scheduleAccountUpdater methods.
  • src/typings/checkout
    • Updates all typings to use readonly properties, and adds constructors.
    • Updates all typings to use a format property on attributeTypeMap.
    • Updates all typings to use string literals instead of string enums.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


A generator's might,
Shapes APIs with all its force,
Typescript takes flight.

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 significantly refactors the TypeScript SDK by upgrading to OpenAPI Generator v7. The changes are extensive and touch upon ESLint configuration, service structure, testing, and typings. Overall, the move to a newer generator version brings a more structured approach to the generated code, especially in typings and object serialization, which is a positive step.

I've focused on areas that might introduce breaking changes, potential regressions, or confusion. Please pay close attention to the comments regarding ESLint configuration, the plans field in CheckoutSessionInstallmentOption, and the deprecation notices in the new Recurring API.

Summary of Findings

  • ESLint Configuration Overhaul: The ESLint configuration has been significantly changed, including the removal of eslint:recommended and plugin:@typescript-eslint/recommended from extends. This requires careful verification to ensure no desired linting rules were unintentionally lost.
  • Potentially Breaking Change in Data Model: The plans field in CheckoutSessionInstallmentOption changed from Array<Enum> to a single Enum. This could be a breaking change if the API previously supported multiple plans.
  • Confusing Deprecation Notices: The newly generated RecurringApi (v68) has methods marked with @deprecated since Adyen Recurring API v68. This is confusing and needs clarification.
  • Incomplete Test Assertions: Found instances of expect; in httpClient.spec.ts which are non-functional and indicate incomplete test assertions.
  • ObjectSerializer Signature Change: The ObjectSerializer.serialize and deserialize methods now consistently include a third format argument (often an empty string), aligning with OpenAPI Generator v7. This change has been applied across the codebase.
  • Service Structure Refactoring: Services like BinLookup, DataProtection, Recurring, etc., have been refactored into a new directory structure with a wrapper API class (e.g., BinLookupAPI containing BinLookupApi). This is a consistent structural improvement.
  • New Services and Tests: New services (PaymentsAppAPI, PosMobileAPI, SessionAuthenticationAPI) have been added along with their initial test suites, which is good progress.

Merge Readiness

This pull request introduces substantial and important changes by upgrading to OpenAPI Generator v7. However, due to the potential impact of the ESLint configuration changes, the data model modification in CheckoutSessionInstallmentOption, and the confusing deprecation notices in the new Recurring API, I recommend addressing these high-severity issues before merging. The incomplete test assertions should also be fixed. I am unable to approve this pull request myself; further review and approval from other maintainers will be necessary once these points are clarified and resolved.

@gcatanese
Copy link
Contributor Author

/gemini review

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 significant refactor to utilize OpenAPI Generator v7, along with generating clients for new services and updating existing ones. The changes are extensive and touch upon ESLint configuration, service structure, testing, and generated typings.

Overall, the move to OpenAPI Generator v7 and the structural improvements (like dedicated ObjectSerializer files and new service wrappers) are positive steps. However, there are a few critical areas that need attention, particularly regarding the ESLint configuration and the deprecation status of the Recurring API methods.

Key areas of feedback:

  • ESLint Configuration: The removal of extends for recommended rule sets needs clarification to ensure linting coverage hasn't unintentionally decreased.
  • API Deprecation: The @deprecated tags on the newly generated RecurringApi methods are a major concern and require immediate clarification.
  • Typing Changes: The shift from Type | null to Type | undefined for optional properties in models could be a breaking change and needs confirmation.
  • Testing: While new tests are good, existing TODOs should be addressed.

Summary of Findings

  • ESLint Configuration Overhaul: The ESLint configuration has been significantly refactored, including the removal of extends for eslint:recommended and plugin:@typescript-eslint/recommended. This needs verification to ensure no essential linting rules were inadvertently lost, potentially impacting code quality. (Severity: Critical)
  • Recurring API Deprecation: Methods in the newly generated src/services/recurring/recurringApi.ts are marked as @deprecated since Adyen Recurring API v68. This is a major concern and requires immediate clarification on whether the API itself or just these generated signatures are deprecated, and what the implications or migration paths are. (Severity: Critical)
  • Typing Changes for Optional Properties (null vs undefined): Optional properties in generated models seem to have changed from Type | null to Type | undefined. This could be a breaking change if null was a previously supported value. Confirmation is needed on the expected representation for absent optional values. (Severity: High)
  • TODOs in Tests: Several // TODO check action is polymorphic comments exist in src/__tests__/checkout.spec.ts. These should be addressed to ensure full test coverage and correctness for polymorphic action types. (Severity: Medium)
  • ObjectSerializer Updates: The ObjectSerializer has been refactored and now includes a third format argument in its serialize and deserialize methods. This is consistently applied across the codebase and appears to be an improvement from the generator. (Severity: Informational - Not commented due to settings)
  • New Service Structure: The introduction of wrapper API classes (e.g., BinLookupAPI in src/services/binLookup/index.ts) экспортирующие specific API groups (e.g., BinLookupApi) is a good structural change, likely improving organization and usability. (Severity: Informational - Not commented due to settings)
  • TSLint Remnants: Some new mock files contain /* tslint:disable */ comments. Since the project uses ESLint, these should be removed or replaced with ESLint equivalents if necessary. (Severity: Low - Not commented due to settings)
  • Missing Newline at End of File: Several new mock and test files are missing a newline character at the end of the file. This should be added if it's part of the project's coding standards. (Severity: Low - Not commented due to settings)

Merge Readiness

This pull request makes substantial progress in upgrading to OpenAPI Generator v7 and expanding service coverage. However, due to the critical nature of the ESLint configuration changes (potential loss of recommended rules) and the uncertainty around the RecurringApi deprecation, I recommend that these points be thoroughly investigated and clarified before merging. Additionally, the potential breaking change regarding null vs undefined in model typings needs confirmation. Addressing the TODOs in tests would also be beneficial. I am unable to approve this pull request in its current state; further review and changes are requested.

@gcatanese gcatanese force-pushed the typescript-openapi-generator branch from 06cb24e to 975feb1 Compare June 4, 2025 11:27
@gcatanese gcatanese force-pushed the typescript-openapi-generator branch from 975feb1 to 23dd113 Compare June 6, 2025 13:47
Copy link

sonarqubecloud bot commented Jun 6, 2025

@gcatanese gcatanese added Feature New feature or request and removed Don't merge labels Jun 10, 2025
@gcatanese gcatanese merged commit 1702cda into main Jun 10, 2025
7 checks passed
@gcatanese gcatanese deleted the typescript-openapi-generator branch June 10, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants