schemars
schemars copied to clipboard
Handling of #[serde(into=...)]
serde(into=AnotherType) makes serde converts the type to AnotherType and then serializes AnotherType. Currently, schemars basically ignores that attribute and emits a schema matching the original type.
This is the behavior I actually need, since I want to serialize a large Vec of tuples. I want the schema to include information about the tuple element names in order to reconstitute a table in Python code with correct column names (pandas DataFrame). However that feels brittle as schemars might change that behavior one day, and that also makes the schema technically wrong. Using an actual array of objects instead of an array of tuples makes the JSON output much larger, needlessly slowing down parsing on the Python end.
Do you have any suggestion on how to handle a case like that ?