This fixes #14. I learned from the other grammars, making the avro schema cleaner than the other implementations. The spec was useful during this stage.
Unions are implemented using standard serde attributes. In the jsonschema module, I left the type as a Value and implemented a helper function to disambiguate Type from a Vec<Type>.
I also avoided the issue with flattening a nested enum by treating the enum as an untagged union. I ran into issues treating the main Type as a tagged-union and adding the serde(tag = "type") attribute on all involved types. This will flatten to the correct json format, but it requires custom deserialization. In the bigquery module, I had to implement a custom deserializer.
I avoided using HashMaps for things that are actually Vecs. In bigquery, I did this because it makes traversal and insertions into the schema simpler. However, most of the manipulation is done within ast now, so having an easily traversable schema by path is no longer of concern.
This fixes #14. I learned from the other grammars, making the avro schema cleaner than the other implementations. The spec was useful during this stage.
https://avro.apache.org/docs/current/spec.html
jsonschema
module, I left the type as aValue
and implemented a helper function to disambiguateType
from aVec<Type>
.https://github.com/acmiyaguchi/jsonschema-transpiler/blob/2de4ca494d8488fac1d4041ddcf88d189bbf3671/src/jsonschema.rs#L79-L85
Type
as a tagged-union and adding theserde(tag = "type")
attribute on all involved types. This will flatten to the correct json format, but it requires custom deserialization. In thebigquery
module, I had to implement a custom deserializer.https://github.com/acmiyaguchi/jsonschema-transpiler/blob/2de4ca494d8488fac1d4041ddcf88d189bbf3671/src/bigquery.rs#L52-L55
bigquery
, I did this because it makes traversal and insertions into the schema simpler. However, most of the manipulation is done withinast
now, so having an easily traversable schema by path is no longer of concern.https://github.com/acmiyaguchi/jsonschema-transpiler/blob/2de4ca494d8488fac1d4041ddcf88d189bbf3671/src/bigquery.rs#L69-L72