{"id":29132371,"url":"https://github.com/expediagroup/javro","last_synced_at":"2025-07-11T04:03:40.263Z","repository":{"id":44168375,"uuid":"334996538","full_name":"ExpediaGroup/javro","owner":"ExpediaGroup","description":"JSON Schema to Avro Mapper","archived":false,"fork":false,"pushed_at":"2024-03-05T02:38:19.000Z","size":512,"stargazers_count":28,"open_issues_count":11,"forks_count":9,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-30T06:44:50.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ExpediaGroup.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE-OF-CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-02-01T15:35:14.000Z","updated_at":"2025-04-19T20:17:29.000Z","dependencies_parsed_at":"2024-03-05T03:47:26.664Z","dependency_job_id":null,"html_url":"https://github.com/ExpediaGroup/javro","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ExpediaGroup/javro","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaGroup%2Fjavro","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaGroup%2Fjavro/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaGroup%2Fjavro/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaGroup%2Fjavro/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ExpediaGroup","download_url":"https://codeload.github.com/ExpediaGroup/javro/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ExpediaGroup%2Fjavro/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262970129,"owners_count":23392534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-30T06:39:39.920Z","updated_at":"2025-07-11T04:03:40.258Z","avatar_url":"https://github.com/ExpediaGroup.png","language":"JavaScript","readme":"# Javro - JSON Schema to Avro Mapper\n\n## Overview\n\nThis library has a specific purpose to generate fully transitive (backward and forward compatible) AVSC (Avro Schema)\nfrom source JSON Schema. The generated AVSC is intended for serialising JSON to Avro, so validation rules are not\ncarried over.\n\nHere are some of its features:\n\n* Creates an AVSC representation of a JSON Schema\n* Follows JSON References used in your input JSON Schema\n* Maintains fully transitive compatibility by:\n    * Reading in the previously generated AVSC from\n      [Confluent's Schema Registry](https://docs.confluent.io/current/schema-registry/index.html)\n    * Making sure any new fields are appended to the end of the previously generated list\n    * Calling Confluent's Schema Registry to perform a FULL_TRANSITIVE check on the new schema\n    * Note you can do a pre-check that your JSON Schema changes are backward compatible using something like\n      [json-schema-diff-validator](https://www.npmjs.com/package/json-schema-diff-validator)\n\nHere's what it doesn't do:\n\n* Try to carry over validation rules\n    * Enums in JSON Schema are primitive fields with validation rules on what's possible to enter in that field. So\n      Javro will convert \n      \n      ```json\n      {\n        \"properties\": {\n          \"example\": {\n            \"type\": \"string\",\n            \"enum\": [\"Foo\", \"Bar\"]\n          }\n        },\n        \"required\": [\"example\"]\n      }\n      ```\n      \n      to\n      \n      ```json\n      {\n        \"name\": \"example\",\n        \"type\": \"string\"\n      }\n      ```\n\n### When would I want to use Javro?\n\nJavro was designed to be used when you've got an application using JSON Schema to validate input JSON data and you then\nwant to feed that JSON data into an Avro data ecosystem (e.g. a Confluent Kafka world). You already know the input data\nis valid, so what you need is AVSC generated from your JSON Schema and another library such as\n[avsc](https://www.npmjs.com/package/avsc) or [json-avro-converter](https://github.com/allegro/json-avro-converter) to\nserialise your input JSON to the Javro generated AVSC.\n\n## Usage\n\nIt's expected that you use Javro as part of an existing JSON Schema build process.\n\n### Add Javro as a dependency in your project\n\nFirst up add Javro to your existing JSON Schema project.\n\n```bash\nnpm install --save-dev javro\n```\n\n### Use Javro in your build\n\nIn your JavaScript-based build you can `require` Javro and call it as follows:\n\n```javascript\nconst { jvro, SchemaRegistryAvroFetcher } = require('javro');\n\njavro({\n  // The location of your JSON Schema\n  jsonSchemaFile: '/path/to/your/jsonSchemaFile.json',\n  \n  // The 'namespace' used in the generated AVSC - the 'name' will be taken either from the 'title' in the JSON Schema or\n  // the file name if 'title' isn't present (in this case that would be 'jsonSchemaFile')\n  namespace: 'your.namespace',\n  \n  // avroFetcher is optional - remove it if you don't care about fully transitive compatibility\n  //   schemaRegistryUrl: the URL of your Confluent Schema Registry where you've registered your schema\n  //   schemaSubject: the Subject you have given your schema in Confluent's Schema Registry. As per Confluent's\n  //                  documentation: \"A subject refers to the name under which the schema is registered\".\n  avroFetcher: new SchemaRegistryAvroFetcher({ schemaRegistryUrl, schemaSubject })\n}).then((jsonSchemaConvertedToAvro) =\u003e {\n  console.log(JSON.stringify(jsonSchemaConvertedToAvro.avsc, null, 2));\n});\n```\n\n### API response\n\nIn the callback from Javro you'll get back an object that looks like this:\n\n```json\n{\n  \"data\": {\n    \"isCompatible\": true,\n    \"avsc\": { ... }\n  }\n}\n```\n\n* `isCompatible` will contain one of `true`, `false`, or `\"AVRO_FETCHER_NOT_FOUND\"` depending on how `avroFetcher`\n  faired\n* `avsc` will contain the generated AVSC as JavaScript objects which can then be serialised using\n  `JSON.stringify(avsc)`\n\n### More Examples\n\nThere are a load of examples contained in [./test/int/](./test/int/).\n\n### Maintaining full transitive compatibility\n\nJavro accepts an optional `avroFetcher` which goes and gets the previous version of a generated AVSC for your schema\nwhich allows Javro to ensure any changes are compatible. There is an implementation `SchemaRegistryAvroFetcher` which\nties into [Confluent's Schema Registry](https://docs.confluent.io/current/schema-registry/index.html) (see example\nabove).\n\nIf you want full transitive compatibility but aren't using Confluent's Schema Registry then you can provide your own\nimplementation.\n \nIf `avroFetcher` is not provided then Javro will return the converted AVSC without maintaining or checking for\ncompatibility with previous version(s).\n\n## Contributing\n\nPull requests are welcome. Please refer to our [CONTRIBUTING](./CONTRIBUTING.md) file.\n\n# Legal\n\nThis project is available under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).\n\nCopyright 2019-2021 Expedia, Inc.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediagroup%2Fjavro","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexpediagroup%2Fjavro","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexpediagroup%2Fjavro/lists"}