Skip to content

Add discriminated union serialization tests - #1860

Draft
jar-stripe wants to merge 1 commit into
masterfrom
jar/discriminated-unions
Draft

Add discriminated union serialization tests#1860
jar-stripe wants to merge 1 commit into
masterfrom
jar/discriminated-unions

Conversation

@jar-stripe

Copy link
Copy Markdown
Contributor

Why?

Validates that the discriminated union type shapes work correctly in stripe-python before codegen produces these patterns. Covers both request-side (TypedDict params with Literal discriminator) and response-side (StripeObject deserialization).

What?

  • Adds tests/test_discriminated_unions.py with 36 tests covering:
    • Standalone union: TypedDicts with Literal["value"] discriminator field (request side)
    • Inline union: discriminator at parent level (request side)
    • Response deserialization via StripeObject.construct_from for both patterns
    • Round-trip serialization/deserialization

See Also

Changelog

No user-facing changes (test-only).

Tests discriminated union type shapes for both request-side (TypedDict
params with Literal discriminator) and response-side (StripeObject
deserialization), covering standalone and inline variants.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Committed-By-Agent: claude
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant