Skip to content

Conversation

@kristapratico
Copy link
Contributor

@kristapratico kristapratico commented Aug 8, 2024

  • I understand that this repository is auto-generated and my pull request may not be merged

Changes being requested

Provides a well-defined behavior / fallback type for response data that doesn't fit any known type in a discriminated union. Aims to handle more gracefully the scenario in which a client may be using a version of the library that does not yet know about a tool type / its response.

Additional context & links

#1574

@kristapratico kristapratico requested a review from a team as a code owner August 8, 2024 00:33
Comment on lines -359 to +363
type_ = field.annotation
if field.metadata:
type_ = wrap_in_annotated_type(field)
else:
type_ = field.annotation
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case where the response data for a union field doesn't conform to expected (i.e. we fail the validate_type call), we seem to lose the metadata (which has the discriminator info) when constructing the field. This makes the code construct the first type present in the union instead of creating the actual known type. Test case illustrating this here

@RobertCraigie RobertCraigie marked this pull request as draft July 10, 2025 11:44
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