Home

Awesome

json-schema-migrate

Migrate JSON-Schema from draft-04 to draft-07, draft-2019-09 or draft-2020-12

build npm coverage

Install

npm install json-schema-migrate

Usage

const migrate = require("json-schema-migrate")
const schema = {
  id: "my-schema",
  minimum: 1,
  exclusiveMinimum: true,
}
migrate.draft7(schema)
// or migrate.draft2019(schema)
// or migrate.draft2020(schema)

console.log(schema)
// {
//  $id: 'my-schema',
//  exclusiveMinimum: 1
// }

You can access Ajv instance that is used to migrate schema using migrate.getAjv function:

console.log(migrate.getAjv().errorsText(errors))

Changes in schemas after migration

License

MIT