Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AJV JSON Schemas Draft 06 Support Update #178

Open
sundeepnarang opened this issue Jul 24, 2017 · 1 comment
Open

AJV JSON Schemas Draft 06 Support Update #178

sundeepnarang opened this issue Jul 24, 2017 · 1 comment

Comments

@sundeepnarang
Copy link

AJV@5 or above cannot add XMLSchema.jsonschema

Requires migration as per AJV (https://github.com/epoberezkin/ajv/releases/tag/5.0.0)

## Migrate your schemas

It is a recommended approach.

Required changes

  • replace id with $id
  • update $schema
  • replace boolean form of exclusiveMaximum/Minimum with numeric form
  • replace Ajv v5 constant with const

Optional changes

  • replace enum with a single allowed value with const
  • replace empty schemas with true
  • replace schemas {"not":{}} with false
  • You can use "migrate" command of ajv-cli to make these changes to your schemas.

You can use "migrate" command of ajv-cli to make these changes to your schemas.

Either we can update docs to keep using Draft04 of JSON schema with following info :

If you need to continue using draft-04 schemas

var ajv = new Ajv({
  meta: false, // optional, to prevent adding draft-06 meta-schema
  extendRefs: true, // optional, current default is to 'fail', spec behaviour is to 'ignore'
  unknownFormats: 'ignore',  // optional, current default is true (fail)
  // ...
});

var metaSchema = require('ajv/lib/refs/json-schema-draft-04.json');
ajv.addMetaSchema(metaSchema);
ajv._opts.defaultMeta = metaSchema.id;

// optional, using unversioned URI is out of spec, see https://github.com/json-schema-org/json-schema-spec/issues/216
ajv._refs['http://json-schema.org/schema'] = 'http://json-schema.org/draft-04/schema';

// Optionally you can also disable keywords defined in draft-06
ajv.removeKeyword('propertyNames');
ajv.removeKeyword('contains');
ajv.removeKeyword('const');

Or we can update jsonschemas using "migrate" command of ajv-cli ?

@sundeepnarang sundeepnarang changed the title AJV Draft 06 Support AJV JSON Schemas Draft 06 Support Update Jul 24, 2017
@sundeepnarang
Copy link
Author

#179 fixes the part of this converting schemas.

Still would need update Jsonix-schema-compiler to create draft 06 schemas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant