Open bmc-msft opened 1 year ago
Note, using the above example with an empty list vs a non-empty list render with Serde as below.
An example without data:
let empty = MyStruct {my_optional_vec: vec![]};
println!("{}", serde_json::to_string_pretty(&empty).unwrap());
results in the following:
{}
An example with data:
let not_empty = MyStruct {my_optional_vec: vec!["with data".to_string()]};
println!("{}", serde_json::to_string_pretty(¬_empty).unwrap());
results in:
{
"my_optional_vec": [
"with data"
]
}
From what I can tell, schemars doesn't support skip_serializing_if
at all
In the following example with
skip_serializing_if
, results in the field still being listed as required.Example using
skip_serializing_if
Resulting schema showing
my_optional_vec
incorrectly as required.