warp
warp copied to clipboard
Query data did not match any variant of untagged enum
Version 0.3.2
Platform MacOS
Description I have query body defined as
#[derive(Deserialize, Serialize)]
#[serde(untagged)]
pub enum MyQuery {
TypeA {
foo_id: Uuid,
bar_id: Uuid,
buzz_id_maybe: Option<Uuid>,
limit: i64,
},
TypeB {
buzz_id: Uuid,
foo_id_maybe: Option<Uuid>,
limit: i64,
},
}
I sent request with query string
foo_id=FOO-UUID&bar_id=BAR-UUID&limit=10
or
foo_id=FOO-UUID&bar_id=BAR-UUID&buzz_id_maybe=BUZZ-UUID&limit=10
both return 400
failed to decode query string, Error("data did not match any variant of untagged enum MyQuery")
but both should match TypeA of MyQuery, any suggestion ?
Looking into thread https://github.com/serde-rs/serde/issues/1183#issuecomment-668324535 found solution https://docs.rs/serde_with/latest/serde_with/struct.DisplayFromStr.html
duplicate to https://github.com/nox/serde_urlencoded/issues/66