{"id":17087903,"url":"https://github.com/geraintluff/json-schema-compatibility","last_synced_at":"2025-07-10T00:37:56.153Z","repository":{"id":12656179,"uuid":"15327931","full_name":"geraintluff/json-schema-compatibility","owner":"geraintluff","description":"Compatibility layer to use v3 JSON Schemas with more modern tools","archived":false,"fork":false,"pushed_at":"2021-12-14T00:28:47.000Z","size":16,"stargazers_count":17,"open_issues_count":2,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-19T22:16:12.137Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geraintluff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-20T02:17:59.000Z","updated_at":"2024-03-14T18:58:17.000Z","dependencies_parsed_at":"2022-09-02T08:51:17.494Z","dependency_job_id":null,"html_url":"https://github.com/geraintluff/json-schema-compatibility","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/geraintluff/json-schema-compatibility","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjson-schema-compatibility","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjson-schema-compatibility/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjson-schema-compatibility/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjson-schema-compatibility/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geraintluff","download_url":"https://codeload.github.com/geraintluff/json-schema-compatibility/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geraintluff%2Fjson-schema-compatibility/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264506265,"owners_count":23619005,"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-10-14T13:35:21.179Z","updated_at":"2025-07-10T00:37:56.135Z","avatar_url":"https://github.com/geraintluff.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Schema compatibility\n\nJSON Schema tools are now being written for v4 of the draft, but v3 schemas still exist out in the wild.\n\nThis project intends to be a converter that updates schemas to be compatible with v4 of the spec.\n\n## Behaviour\n\nThis tool works \"in-place\" - so it actually modifies the JavaScript objects representing the schema.  This is simply because it's easier than cloning the data or anything like that.\n\nThis tool should also not modify schemas that are already compatible, and can even (in some cases) handle horrible merged combinations (e.g. mixed boolean/array use of `required`).\n\n## Usage (Node):\n\nInstall using npm:\n\n```shell\nnpm install json-schema-compatibility\n```\n\nConvert a schema:\n\n```\nvar api = require('json-schema-compatibility');\n\napi.v4(oldSchema);\n```\n\n## Usage (browser)\n\nThis has not been thoroughly tested, but it should make the API available as a global `JsonSchemaCompatibility` variable.\n\nYou might need a shim to get it to work in older browsers (due to use of `Array.isArray()` etc), but I'd imagine any JSON Schema validator would already include/require that.\n\n## Combination with other packages\n\nThe idea is that you can take your v3 schemas, and pass them through this tool before handing them to a v4 utility.  For instance, using tv4:\n\n```javascript\nvar oldSchema = {\"type\": \"number\", \"divisibleBy\": 1.5};\nvar v4Schema = JsonSchemaCompatibility.v4(oldSchema);\n\ntv4.validate(data, v4Schema);\n```\n\n## Known issues/bugs\n\nAll versions of `json-schema-compatibility` will produce incorrect behaviour in the following situation:\n```json\n{\n    \"type\": \"object\",\n    \"properties\": {\n        \"foo\": {\"$ref\": \"#items\"}\n    },\n    \"items\": {\n        \"id\": \"#items\",\n        \"required\": true\n    }\n}\n```\n\nThis is because to properly update `/properties/foo`, it needs to resolve `#items`.  In the general case, it can't update a schema until it's fetched every schema that's referenced, which is beyond the syntactic-only fixes that we perform right now.\n\nIf you encounter this issue, give me a shout.\n\n## License\n\nThe code is available as \"public domain\", meaning that it is completely free to use, without any restrictions at all.  Read the full license [here](http://geraintluff.github.com/tv4/LICENSE.txt).\n\nIt's also available under an [MIT license](http://jsonary.com/LICENSE.txt).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fjson-schema-compatibility","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeraintluff%2Fjson-schema-compatibility","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeraintluff%2Fjson-schema-compatibility/lists"}