You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement a oneOf POST route, but I'm getting an error indicating that:
"json: cannot unmarshal object into Go value of type MyInterface"
So far my only way to bypass this has been to declare an any type and then unmarshall the body myself, but that seems counter productive since I went through the effort of providing a Discriminator and the validation that huma provides appears to be working correct.
Obviously I can switch on the discriminator field myself and unmarhsall into the correct type, but it just feels like I'm doing something wrong here (perhaps many things wrong).
Apologies if this ends up being trivial, this is my first route with Huma.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to implement a oneOf POST route, but I'm getting an error indicating that:
"json: cannot unmarshal object into Go value of type MyInterface"
So far my only way to bypass this has been to declare an any type and then unmarshall the body myself, but that seems counter productive since I went through the effort of providing a Discriminator and the validation that huma provides appears to be working correct.
Obviously I can switch on the discriminator field myself and unmarhsall into the correct type, but it just feels like I'm doing something wrong here (perhaps many things wrong).
Apologies if this ends up being trivial, this is my first route with Huma.
Here is my setup:
Again, the handler never executes and "Did I make it?" is never printed. It works great if I change Body to any, but it seems slightly self defeating.
Thanks for the help!
Beta Was this translation helpful? Give feedback.
All reactions