From 47fc346c7fa1f3acde0871bb1a9eb51963e324e4 Mon Sep 17 00:00:00 2001 From: Alex Bair Date: Tue, 24 Sep 2024 12:50:27 -0400 Subject: [PATCH] source-stripe-native: make created optional for Accounts Sometimes, `account.updated` events do not have `created` in the document, causing failures when we validate the document against its model. Allowing a default value of `None` optional will avoid these failures and reflect the API's actual response. Note: We remove the `None` default value with a lambda to keep the schema more inline with what actually happens: the `created` field is either present as an `int` or it's not present at all. --- source-stripe-native/source_stripe_native/models.py | 6 ++++++ .../tests/snapshots/snapshots__discover__stdout.json | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source-stripe-native/source_stripe_native/models.py b/source-stripe-native/source_stripe_native/models.py index 5e811a147..c529b9820 100644 --- a/source-stripe-native/source_stripe_native/models.py +++ b/source-stripe-native/source_stripe_native/models.py @@ -151,6 +151,12 @@ class Accounts(BaseStripeObjectWithEvents): "account.updated": "u", } + # Accounts docs returned in account.updated events may not have a created field. + created: int = Field( + default=None, + # Don't schematize the default value. + json_schema_extra=lambda x: x.pop('default') # type: ignore + ) # Could not verify Persons events are generated in test mode, but suspect # they are generated in Stripe's live mode. diff --git a/source-stripe-native/tests/snapshots/snapshots__discover__stdout.json b/source-stripe-native/tests/snapshots/snapshots__discover__stdout.json index bd6c32380..07cbbfd5a 100644 --- a/source-stripe-native/tests/snapshots/snapshots__discover__stdout.json +++ b/source-stripe-native/tests/snapshots/snapshots__discover__stdout.json @@ -59,8 +59,7 @@ }, "required": [ "id", - "object", - "created" + "object" ], "title": "Accounts", "type": "object",