How to properly create a oneof in Python? #1200
Unanswered
ottmar-zittlau
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I have some issues creating a oneof in Python.
I'd like to implement a oneof with three options:
The generator correctly generates a request for this comprising all these options:
The websocket endpoint looks like this:
My async generator looks like this:
This doesn't seem to work, because if I wrap my request in
Models.DoSomethingRequest
in the yield command, the json that is sent seems to ignore the oneof-character of this message. Somewhere pydanticsmodel_dump_json
is called on this message which will also includeoneof_schema_1_validator
etc.If I just call
yield request
, everything works, but MyPy complains that the types don't match. I could disable this warning, but somehow it feels wrong.I noticed that there is a
to_json
method of theDoSomethingRequest
-class, which seems to do the correct thing, but it doesn't seem to get called. Do I have to setup something to make this work?Thanks and best regards
oz
Beta Was this translation helpful? Give feedback.
All reactions