Giter VIP home page Giter VIP logo

clemensv / avrotize Goto Github PK

View Code? Open in Web Editor NEW
54.0 3.0 1.0 1.25 MB

Avrotize is a command-line tool for converting data structure definitions between different schema formats, using Apache Avro Schema as the integration schema model.

License: Apache License 2.0

Python 86.94% C# 0.84% Java 1.95% Jinja 4.79% PowerShell 0.12% Shell 0.04% JavaScript 0.16% TypeScript 5.17%
asn1 avro avro-schema avro-schemas json-schema protobuf protocol-buffers xsd xsd-schema csharp

avrotize's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

jcvanderwal

avrotize's Issues

Suggested change to preserve long type going to and then back from JSON Schema

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':

Avro namespaces are optional, but required for Avrotize

According to the Apache Avro Spec, namespaces are optional. We don't use them since some tools do not support them, and thus not using them ensures we don't have conflicting names.

Namespaces appear to be required for avrotize though:

 File "avro/python/venv/lib/python3.12/site-packages/avrotize/avrotoproto.py", line 353, in convert_avro_to_proto
    avrotoproto.convert_avro_to_proto(avro_schema_path, proto_file_path)
  File "avro/python/venv/lib/python3.12/site-packages/avrotize/avrotoproto.py", line 346, in convert_avro_to_proto
    self.avro_schema_to_proto_messages(avro_schema, proto_files)
  File "avro/python/venv/lib/python3.12/site-packages/avrotize/avrotoproto.py", line 264, in avro_schema_to_proto_messages
    self.avro_schema_to_proto_message(avro_schema, proto_files)
  File "avro/python/venv/lib/python3.12/site-packages/avrotize/avrotoproto.py", line 243, in avro_schema_to_proto_message
    file = ProtoFile({}, {}, {}, [], {}, avro_schema["namespace"])

Missing dependency "requests" with clean install (python 3.12)

New machine, fresh python 3.12 + pip:

> pipenv install
> pip install avrotize
> avrotize
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\oisin\AppData\Local\Programs\Python\Python312\Scripts\avrotize.exe\__main__.py", line 4, in <module>
  File "C:\Users\oisin\AppData\Local\Programs\Python\Python312\Lib\site-packages\avrotize\avrotize.py", line 9, in <module>
    from avrotize.jsonstoavro import convert_jsons_to_avro
  File "C:\Users\oisin\AppData\Local\Programs\Python\Python312\Lib\site-packages\avrotize\jsonstoavro.py", line 6, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

After having ran "pip install requests" all looks good now.

Not at 1.0 yet

If something isn't working, tell me. Just know that I'm working on this with high intensity to cover corner cases, and those sometimes surface the need for dramatic changes. Especially JSOn Schema, as practiced in the wild, is a grand source of hard puzzles.

I'll close this issue once I'm happy wheer things are at and THEN I will start to log bugs for what remains to be done.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.