Repository navigation
Conversation
added 2 commits
October 15, 2026 09:48
…know The API can return enum values added after the SDK was generated. For example, Italian PagoBancomat cards are returned with card type "BANCOMAT", which is missing from CardResponseType: Transactions::get() then throws a ValueError and the whole transaction is unreadable, even though it is SUCCESSFUL and every other field is valid. Enums that declare an UNKNOWN case now map unrecognised values to it. Enums without UNKNOWN keep the current strict behaviour (ValueError).
Italian PagoBancomat debit cards are reported by the API with card type "BANCOMAT". Add it to the CardType schema and regenerate the card type enums.
matoous
force-pushed
the
fix/unknown-enum-fallback
branch
from
October 15, 2026 07:51
9fd1d60 to
99170fb
Compare
Contributor
|
Hi! Thanks for the contribution. We generate the SDKs from our OpenAPI specs, so the fix needed to go there (done) and #119 re-generates the SDK from updated specs. I will close your PR in favor of the automatic sync. Separately, I am taking a look into keeping the enums open (which should have been the behavior in the first place). Thank you 🙇 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #127
Problem
The Transactions API returns
card.type = "BANCOMAT"for Italian PagoBancomat debit cards. The value is missing from theCardTypeschema, so the hydrator throws aValueErrorandTransactions::get()cannot return a successful transaction at all.Changes
This PR has two independent commits, so they can be reviewed (or taken) separately:
fix(hydrator): whentryFrom()does not recognise a value,Hydrator::castEnumValue()now returns the enum'sUNKNOWNcase if the enum declares one (CardType,CardResponseType,ReaderStatus,MemberStatus, …). Enums withoutUNKNOWNkeep the current strict behaviour, sotestHydrateInvalidBackedEnumValueThrowsValueErroris unchanged and still passes. This keeps responses readable when the API adds a value before the SDK is regenerated.feat: add BANCOMAT card type: addsBANCOMATtocomponents.schemas.CardTypeinopenapi.jsonand regenerates the four derived enums with the codegen (go -C codegen run . generate ../openapi.json ../src). Running the generator on the unmodified spec produces no diff, so the only changes are theBANCOMATcases.I noticed
openapi.jsonis synced fromsumup/apis. If the spec change should go there instead, I'm happy to drop the second commit; the first one fixes the crash on its own.Tests
testHydrateUnknownValueOfEnumWithUnknownCaseFallsBackToUnknown: an unknown card network hydrates toCardResponseType::UNKNOWNand the other fields are kept.testHydrateBancomatCardType:BANCOMAThydrates toCardResponseType::BANCOMAT.Locally on PHP 8.5: PHPUnit is green (37 tests) and php-cs-fixer reports no changes. PHPStan reports the same 2 errors in
HttpClient/GuzzleClient.phpthat are already present onmain.