Skip to content

kanishka-malhotra/jsonschema-avro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

71 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jsonschema-avro

Parent Project: thedumbterminal/jsonschema-avro

Build Status

Converts JSON-schema definitions into Avro definitions.

Install

npm install --save dipsmishra/jsonschema-avro#master

Consume

const jsonSchemaAvro = require('jsonschema-avro')

const inJson = {
	"description": "Example description",
	"type": "object",
	"properties": {
		"first_name": { "type": "string" },
		"address": {
			"type": "object",
			"properties": {
				"street_address": { "type": "string" }
			}
		}
	}
}

jsonSchemaAvro.convert(inJson)
    .then(avro => {
        // use avro schema here
    }).catch(err => {
        // handle error here
    });

Options

jsonSchemaAvro.convert(inJson, recordSuffix, splitIdForName)

Parameters

  • inJson: (mandatory) JSON schema object to convert to Avro
  • recordSuffix: (optional) Suffix to be appended to the name of each record type (default: '_record')
  • splitIdForName: (optional) Split id in schema to obtain namespace and name (default: false) Note: a custom suffix may be provided to the name by specifying it as a string value for this option
  • enumSuffix: (optional) Suffix for enum types (default: '_enum') Note: a custom suffix may be provided to all enums by specifying it as a string value for this option

All external references are resolved using the excellent json-schema-ref-parser.

Test

npm test

TODO

  • More tests for edge cases.

About

Convert JSON-Schema into Avro

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%