json-schema-to-avro

Convert JSON Schema into Apache Avro schema

Usage no npm install needed!

<script type="module">
  import jsonSchemaToAvro from 'https://cdn.skypack.dev/json-schema-to-avro';
</script>

README

json-schema-to-avro

npm Build Status

Converts JSON Schema definitions into Avro Schema definitions.

Install

npm install json-schema-to-avro

Consume

    const jsonSchemaAvro = require('json-schema-to-avro')

    const inJson = {
      "$id": "http://your-domain.com/schemas/your-schema.json"
      "description": "Example description",
      "type": "object",
      "properties": {
        "first_name": { "type": "string" },
        "address": {
          "type": "object",
          "properties": {
            "street_address": { "type": "string" }
          }
        }
      }
  }

  const avro = jsonSchemaAvro.convert(inJson)

Please ensure that the input JSON schema is dereferenced so that all external references have been resolved. json-schema-ref-parser can do this, prior to using this module.

Test

npm test

TODO

  • Handle anyOf and allOf.