Suggested change to preserve long type going to and then back from JSON Schema
dschmitt2 opened this issue · comments
First off, thanks for making this tool available!
I'd like to suggest the following change to preserve the 'long' type when going to JSON Schema and then back to Avro.
diff --git a/avrotize/jsonstoavro.py b/avrotize/jsonstoavro.py
index e20fc6a..9803ee8 100644
--- a/avrotize/jsonstoavro.py
+++ b/avrotize/jsonstoavro.py
@@ -358,7 +358,10 @@ class JsonToAvroConverter:
if json_primitive == 'string':
avro_primitive = 'string'
elif json_primitive == 'integer':
- avro_primitive = 'int'
+ if format == 'int64':
+ avro_primitive = 'long'
+ else:
+ avro_primitive = 'int'
elif json_primitive == 'number':
avro_primitive = 'float'
elif json_primitive == 'boolean':
The number type in JSON Schema doesn't have a format qualifier by what I can see. I am going to add this, nevertheless, but I'd like to see examples where that is used in the wild.