I have this code which fails. I believe it should be supported.
#[serde_as]
#[skip_serializing_none]
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Demo {
#[serde_as(as = "Option<OneOrMany<_>>")]
contents: Option<Vec<String>>,
}
It serializes fine with a single element in a vector or multiple elements in a vector
It fails with an error when the contents are set to None
failures:
---- tests::vec_none stdout ----
None
Serialized ---
{}
Error: Message("missing field contents", Some(Pos { marker: Marker { index: 4, line: 2, col: 0 }, path: "." }))
Please find a test case attached.
Workaround: Dont specify #[skip_serializing_none]
test.txt