Skip to content

Commit

Permalink
source-stripe-native: make created optional for Accounts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alex-Bair committed Sep 24, 2024
1 parent 911128f commit 47fc346
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions source-stripe-native/source_stripe_native/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
},
"required": [
"id",
"object",
"created"
"object"
],
"title": "Accounts",
"type": "object",
Expand Down

0 comments on commit 47fc346

Please sign in to comment.