When working with untagged enums, I often derive Serialize/Deserialize
manually, because serde's default error reporting for untagged enums can be very vague. However, since they still behave just like untagged enums, I'd like to be able to derive ToSchema
on them. In short, I'd like this to work:
#[derive(ToSchema)]
#[serde(untagged)]
pub enum MyEnum {
A(String),
B(u64),
}
impl<'de> Deserialize<'de> for MyEnum {
// Manual Deserialize implementation...
}
impl Serialize for MyEnum {
// Manual Serialize implementation...
}
The only reason this gets rejected is because serde
isn't listed as one of the helpers for ToSchema
(which it is, since ToSchema
looks at serde tags). It should be an easy and non-breaking change, I can make a PR for it.