https://github.com/thedumbterminal/jsonschema-avro
Convert JSON-Schema into Avro
https://github.com/thedumbterminal/jsonschema-avro
avro json-schema node-js node-module nodejs nodejs-module nodejs-modules
Last synced: 9 months ago
JSON representation
Convert JSON-Schema into Avro
- Host: GitHub
- URL: https://github.com/thedumbterminal/jsonschema-avro
- Owner: thedumbterminal
- License: mit
- Created: 2017-06-10T09:52:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-11-04T01:36:54.000Z (over 1 year ago)
- Last Synced: 2025-06-17T13:08:56.470Z (12 months ago)
- Topics: avro, json-schema, node-js, node-module, nodejs, nodejs-module, nodejs-modules
- Language: JavaScript
- Homepage:
- Size: 643 KB
- Stars: 22
- Watchers: 3
- Forks: 17
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# jsonschema-avro
[](https://www.npmjs.com/package/jsonschema-avro)
[](https://github.com/thedumbterminal/jsonschema-avro/actions/workflows/main.yml)
Converts JSON-schema definitions into Avro definitions.
## Install
npm install jsonschema-avro
## 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" }
}
}
}
}
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](https://www.npmjs.com/package/@apidevtools/json-schema-ref-parser) can do this, prior to using this module.
## Develop
Avro schema documentation can be found here:
https://docs.oracle.com/cd/E26161_02/html/GettingStartedGuide/avroschemas.html
### Testing
To run all tests:
npm test
To run a single test, using the name of the sample:
ONLY=optional npm test
CI uses the following script:
```
npm run ci
```
Please run this on your local machine to ensure CI will pass.
### Code style
This project uses prettier, to format source files run:
npm run format
Please keep the integration tests to a single test per file for readability.
## TODO
- Handle `anyOf` and `allOf`.