From e33e17e3145d4a4e084cb3ff5af24bca69ce4a3e Mon Sep 17 00:00:00 2001 From: beppe Date: Thu, 13 Nov 2025 17:01:11 +0100 Subject: [PATCH 1/4] Add Classic prefix to templates --- templates/api-single.mustache | 2 +- templates/api.mustache | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/api-single.mustache b/templates/api-single.mustache index 8d535189..9fc9447c 100644 --- a/templates/api-single.mustache +++ b/templates/api-single.mustache @@ -23,7 +23,7 @@ module Adyen {{#apiInfo}} {{#apis}} def {{classFilename}} - @{{classFilename}} ||= Adyen::{{classname}}.new(@client, @version) + @{{classFilename}} ||= Adyen::{{classicPrefix}}{{classname}}.new(@client, @version) end {{/apis}} diff --git a/templates/api.mustache b/templates/api.mustache index 25a091c0..4bde74dd 100644 --- a/templates/api.mustache +++ b/templates/api.mustache @@ -6,7 +6,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class {{classname}} < Service + class {{classicPrefix}}{{classname}} < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) From 47ea1d7b35995749d4cc45d75dbe5041ae99d5f7 Mon Sep 17 00:00:00 2001 From: beppe Date: Thu, 13 Nov 2025 17:02:32 +0100 Subject: [PATCH 2/4] Generate code to add Classic prefix --- lib/adyen/services/payment.rb | 4 ++-- lib/adyen/services/payment/modifications_api.rb | 2 +- lib/adyen/services/payment/payments_api.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/adyen/services/payment.rb b/lib/adyen/services/payment.rb index 9dd096c7..28b55f62 100644 --- a/lib/adyen/services/payment.rb +++ b/lib/adyen/services/payment.rb @@ -18,11 +18,11 @@ def initialize(client, version = DEFAULT_VERSION) end def modifications_api - @modifications_api ||= Adyen::ModificationsApi.new(@client, @version) + @modifications_api ||= Adyen::ClassicModificationsApi.new(@client, @version) end def payments_api - @payments_api ||= Adyen::PaymentsApi.new(@client, @version) + @payments_api ||= Adyen::ClassicPaymentsApi.new(@client, @version) end end diff --git a/lib/adyen/services/payment/modifications_api.rb b/lib/adyen/services/payment/modifications_api.rb index 72839370..88e95c32 100644 --- a/lib/adyen/services/payment/modifications_api.rb +++ b/lib/adyen/services/payment/modifications_api.rb @@ -5,7 +5,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class ModificationsApi < Service + class ClassicModificationsApi < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) diff --git a/lib/adyen/services/payment/payments_api.rb b/lib/adyen/services/payment/payments_api.rb index 94f762a3..e50d032b 100644 --- a/lib/adyen/services/payment/payments_api.rb +++ b/lib/adyen/services/payment/payments_api.rb @@ -5,7 +5,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class PaymentsApi < Service + class ClassicPaymentsApi < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) From 7a69afeac69e063e88d8489efbd46eef1b4f522a Mon Sep 17 00:00:00 2001 From: beppe Date: Thu, 13 Nov 2025 17:02:49 +0100 Subject: [PATCH 3/4] Add test --- spec/checkout_spec.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/checkout_spec.rb b/spec/checkout_spec.rb index 2c0e6739..6629f259 100644 --- a/spec/checkout_spec.rb +++ b/spec/checkout_spec.rb @@ -8,6 +8,38 @@ service: 'Checkout' } end + + it 'detects a namespace collision between Checkout and Payment PaymentsApi classes' do + # Load both auto-generated PaymentsApi classes manually + payment_api_path = File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__) + checkout_api_path = File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__) + + load payment_api_path + load checkout_api_path + + # Instantiate what the Checkout facade will call + checkout = Adyen::Checkout.new(@shared_values[:client]) + + # Retrieve the PaymentsApi class reference that the facade resolves to + resolved_class = checkout.payments_api.class + + # Verify which service it actually represents + service_name = + if resolved_class.instance_methods.include?(:service_name) + resolved_class.new(@shared_values[:client], @shared_values[:client].checkout.version).service_name + else + resolved_class.to_s + end + + puts "service_name" + puts service_name + # This expectation documents the current buggy behavior. + # It should fail once the namespace is properly fixed. + expect(service_name) + .to eq('Adyen::PaymentsApi'), + "Expected Checkout.payments_api to instantiate the Checkout::PaymentsApi class, " \ + "but it appears to be using the Payment service implementation instead (#{resolved_class})" + end # must be created manually because every field in the response is an array it 'makes a payment_methods call' do From c7ffb12bd1d7240ef008dcf7394df8f62fe91bc9 Mon Sep 17 00:00:00 2001 From: beppe Date: Thu, 13 Nov 2025 17:26:58 +0100 Subject: [PATCH 4/4] Refactor test --- spec/checkout_spec.rb | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/spec/checkout_spec.rb b/spec/checkout_spec.rb index 6629f259..a9a688ac 100644 --- a/spec/checkout_spec.rb +++ b/spec/checkout_spec.rb @@ -9,36 +9,17 @@ } end - it 'detects a namespace collision between Checkout and Payment PaymentsApi classes' do - # Load both auto-generated PaymentsApi classes manually - payment_api_path = File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__) - checkout_api_path = File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__) + it 'uses the correct PaymentsApi for the Checkout service' do + # Load both API files to ensure there's no conflict after the fix. + load File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__) + load File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__) - load payment_api_path - load checkout_api_path - - # Instantiate what the Checkout facade will call checkout = Adyen::Checkout.new(@shared_values[:client]) + payments_api = checkout.payments_api - # Retrieve the PaymentsApi class reference that the facade resolves to - resolved_class = checkout.payments_api.class - - # Verify which service it actually represents - service_name = - if resolved_class.instance_methods.include?(:service_name) - resolved_class.new(@shared_values[:client], @shared_values[:client].checkout.version).service_name - else - resolved_class.to_s - end - - puts "service_name" - puts service_name - # This expectation documents the current buggy behavior. - # It should fail once the namespace is properly fixed. - expect(service_name) - .to eq('Adyen::PaymentsApi'), - "Expected Checkout.payments_api to instantiate the Checkout::PaymentsApi class, " \ - "but it appears to be using the Payment service implementation instead (#{resolved_class})" + # Verify that the Checkout facade uses the correct PaymentsApi class. + expect(payments_api.class.name).to eq('Adyen::PaymentsApi') + expect(payments_api.service).to eq('Checkout') end # must be created manually because every field in the response is an array