{"id":21451168,"url":"https://github.com/lenra-io/json-schema-unifier","last_synced_at":"2025-03-17T02:41:17.006Z","repository":{"id":192549630,"uuid":"686462268","full_name":"lenra-io/json-schema-unifier","owner":"lenra-io","description":"Unifies many JSON Schema files into a single file","archived":false,"fork":false,"pushed_at":"2024-04-08T21:00:00.000Z","size":299,"stargazers_count":0,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-24T04:45:34.590Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lenra-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"github":["lenra-io"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-09-02T21:51:20.000Z","updated_at":"2023-09-14T10:15:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"86d6b0c4-67b0-464a-bc49-8cbf48d6190c","html_url":"https://github.com/lenra-io/json-schema-unifier","commit_stats":null,"previous_names":["taorepoara/json-schema-unifier"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fjson-schema-unifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fjson-schema-unifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fjson-schema-unifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lenra-io%2Fjson-schema-unifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lenra-io","download_url":"https://codeload.github.com/lenra-io/json-schema-unifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243963779,"owners_count":20375676,"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":"2024-11-23T04:18:29.368Z","updated_at":"2025-03-17T02:41:16.990Z","avatar_url":"https://github.com/lenra-io.png","language":"TypeScript","funding_links":["https://github.com/sponsors/lenra-io"],"categories":[],"sub_categories":[],"readme":"\u003cdiv id=\"top\"\u003e\u003c/div\u003e\n\u003c!--\n*** This README was created with https://github.com/othneildrew/Best-README-Template\n--\u003e\n\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n\n\u003ch3 align=\"center\"\u003eApp Lib for javaScript based projects\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    Unifies many JSON Schema files into a single file.\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/lenra-io/json-schema-unifier/issues\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/lenra-io/json-schema-unifier/issues\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\nTo unify many JSON Schema files into a single file, create a main JSON Schema file that correspond to the main element to check and has `$ref` to the other ones.\n\n```json\n// person.schema.json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"$id\": \"https://example.com/person.schema.json\",\n  \"title\": \"Person\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"firstName\": {\n      \"type\": \"string\",\n      \"description\": \"The person's first name.\"\n    },\n    \"lastName\": {\n      \"type\": \"string\",\n      \"description\": \"The person's last name.\"\n    },\n    \"age\": {\n      \"description\": \"Age in years which must be equal to or greater than zero.\",\n      \"type\": \"integer\",\n      \"minimum\": 0\n    },\n    \"address\": {\n      \"$ref\": \"address.schema.json\"\n    }\n  }\n}\n```\n\nCreate the referenced files:\n\n```json\n// address.schema.json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"$id\": \"https://example.com/address.schema.json\",\n  \"title\": \"Address\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"streetAddress\": {\n      \"type\": \"string\"\n    },\n    \"city\": {\n      \"type\": \"string\"\n    },\n    \"state\": {\n      \"type\": \"string\"\n    },\n    \"country\": {\n      \"type\": \"string\"\n    }\n  },\n  \"required\": [\"streetAddress\", \"city\", \"state\", \"country\"]\n}\n```\n\nThe references are resolved recursively and the result is a single file with all the definitions.\n\n```json\n// unified.schema.json\n{\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\n  \"$id\": \"https://example.com/person.schema.json\",\n  \"title\": \"Person\",\n  \"type\": \"object\",\n  \"properties\": {\n    \"firstName\": {\n      \"type\": \"string\",\n      \"description\": \"The person's first name.\"\n    },\n    \"lastName\": {\n      \"type\": \"string\",\n      \"description\": \"The person's last name.\"\n    },\n    \"age\": {\n      \"description\": \"Age in years which must be equal to or greater than zero.\",\n      \"type\": \"integer\",\n      \"minimum\": 0\n    },\n    \"address\": {\n      \"$ref\": \"#/definitions/address\"\n    }\n  },\n  \"definitions\": {\n    \"address\": {\n      \"title\": \"Address\",\n      \"type\": \"object\",\n      \"properties\": {\n        \"streetAddress\": {\n          \"type\": \"string\"\n        },\n        \"city\": {\n          \"type\": \"string\"\n        },\n        \"state\": {\n          \"type\": \"string\"\n        },\n        \"country\": {\n          \"type\": \"string\"\n        }\n      },\n      \"required\": [\"streetAddress\", \"city\", \"state\", \"country\"]\n    }\n  }\n}\n```\n\n### as a CLI\n\nTo use the CLI, install the package globally:\n\n```bash\nnpm install -g @lenra/json-schema-unifier\n```\n\nThen run the command:\n\n```bash\njson-schema-unifier person.schema.json\n```\n\nBy default, the output is printed to the console. To save it to a file, use the `--output` option:\n\n```bash\njson-schema-unifier person.schema.json --output unified.schema.json\n```\n\nYou also can specify the output format with the `--format` option. The available formats are `json` and `yaml`:\n\n```bash\njson-schema-unifier person.schema.json --format yaml\n```\n\nA `--verbose` option is also available to print the logs to the console.\n\n### as a Library\n\nTo use the library, install it as a dependency:\n\n```bash\nnpm install @lenra/json-schema-unifier\n```\n\nThen import it in your code:\n\n```js\nimport { JsonSchemaUnifier } from '@lenra/json-schema-unifier';\n\nconst result = JsonSchemaUnifier.unify('person.schema.json');\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please open an issue with the tag \"enhancement\".\nDon't forget to give the project a star if you liked it! Thanks again!\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the **MIT** License. See [LICENSE](./LICENSE) for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nLenra - [@lenra_dev](https://twitter.com/lenra_dev) - contact@lenra.io\n\nProject Link: [https://github.com/lenra-io/json-schema-unifier](https://github.com/lenra-io/json-schema-unifier)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/lenra-io/json-schema-unifier.svg?style=for-the-badge\n[contributors-url]: https://github.com/lenra-io/json-schema-unifier/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/lenra-io/json-schema-unifier.svg?style=for-the-badge\n[forks-url]: https://github.com/lenra-io/json-schema-unifier/network/members\n[stars-shield]: https://img.shields.io/github/stars/lenra-io/json-schema-unifier.svg?style=for-the-badge\n[stars-url]: https://github.com/lenra-io/json-schema-unifier/stargazers\n[issues-shield]: https://img.shields.io/github/issues/lenra-io/json-schema-unifier.svg?style=for-the-badge\n[issues-url]: https://github.com/lenra-io/json-schema-unifier/issues\n[license-shield]: https://img.shields.io/github/license/lenra-io/json-schema-unifier.svg?style=for-the-badge\n[license-url]: https://github.com/lenra-io/json-schema-unifier/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fjson-schema-unifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flenra-io%2Fjson-schema-unifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flenra-io%2Fjson-schema-unifier/lists"}