diff --git a/cli.js b/cli.js index a193fe05297ca36ec49acb40528614bf280a7335..2046fa047b66a0d4c52166e0fd759ca9df65f313 100755 --- a/cli.js +++ b/cli.js @@ -36,6 +36,9 @@ var argv = require('optimist') .alias('e', 'schema-extension') .describe('e', 'JSON Schema file extension eg. schema.json or json') .alias('n', 'no-readme') + .describe('v', 'JSON Schema Draft version to use. Supported: 04, 06, 07 (default)') + .alias('v', 'draft') + .default('v', '07') .describe('n', 'Do not generate a README.md file in the output directory') .describe('link-*', 'Add this file as a link the explain the * attribute, e.g. --link-abstract=abstract.md') .check(function(args) { @@ -50,8 +53,14 @@ var argv = require('optimist') const docs = _.fromPairs(_.toPairs(argv).filter(([ key, value ]) => { return key.startsWith('link-'); }).map(([ key, value ]) => { return [ key.substr(5), value ];})); -var ajv = new Ajv({ allErrors: true, messages:true }); -ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); +var ajv = new Ajv({ allErrors: true, messages:true, schemaId: 'auto' }); +console.log(argv.v); +if (argv.v === '06'||argv.v === 6) { + console.log('enabling draft-06 support'); + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-06.json')); +} else if (argv.v === '04' || argv.v === 4) { + ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json')); +} var schemaPathMap = {}; var metaElements = {}; var schemaPath = path.resolve(argv.d); diff --git a/spec/lib/integrationTest.spec.js b/spec/lib/integrationTest.spec.js index 929ff0d7456e041d4b5dbec146e0efe53a416170..ae86bfb2ee00bc9e606ac2c797fb6f820d2342f3 100644 --- a/spec/lib/integrationTest.spec.js +++ b/spec/lib/integrationTest.spec.js @@ -48,7 +48,8 @@ describe('Compare results', () => { '--link-abstract', 'abstract.md', '--link-status', - 'status.md' + 'status.md', + '-v', '06' ]); ls.on('close', code => { expect(code).toEqual(0);