-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Union type as response model #233
Labels
Comments
For anyone else running into this issue, I've managed to fix it using a custom pydantic converter with a wrapper model class. This leverages the union support of pydantic:
|
FTR, I shared the hopefully generic implementation I came up with combining various solutions found here and in the discussion #255. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
It would be nice if Uplink could support Union types as response model. We're using Uplink (with Pydantic) to automatically generate a client. An example method (simplified) that it will generate is as follows:
This will throw an error:
TypeError: issubclass() arg 1 must be a class
becauseUnion
is not a class (see stack trace below for more info)Describe the solution you'd like
It would be nice if uplink could support Union types as response models. Pydantic has this feature, where you need to make sure to put the in the right order, as the first schema that matches will be taken. Something similar (maybe leaning on the implementation in Pydantic) would be a great addition I think. Pydantic feature docs: https://pydantic-docs.helpmanual.io/usage/types/#unions
Additional context
Error log when using Union type:
The text was updated successfully, but these errors were encountered: