Open waywardmonkeys opened 6 years ago
Perhaps related to this is this:
"legend": {
"anyOf": [
{
"$ref": "#/definitions/Legend"
},
{
"type": "null"
}
],
"description": "An object defining properties of the legend.\nIf `null`, the legend for the encoding channel will be removed.\n\n__Default value:__ If undefined, default [legend properties](legend.html) are applied."
},
Which gets translated to:
pub legend: Option<serde_json::Value>,
But I think that should be Option<Legend>
.
There is a bit of code that handles anyOf
where there can either be just an element of some type or an array of that type
or it falls back to emitting serde_json::Value
You would want to extend that bit to check for "type": "null"
+ some other type
and then emit an Option<some other type>
Thanks! I started looking at this this evening. I will poke at it more and submit a PR this week.
FYI: as we've sort of discussed elsewhere, QuickType handles all of this pretty well.
In the Vega Lite schema, there is this property on an
Axis
:This is coming out in the generated Rust as:
I really think that should be
Option<String>
though?