fix: v5 with "schemas" option when schemas dont have $schema keyword (or use v5 metaschema), closes #204
parent
9a9ba82729
commit
95c40a55d4
|
@ -65,10 +65,11 @@ function Ajv(opts) {
|
|||
if (opts.errorDataPath == 'property') opts._errorDataPathProperty = true;
|
||||
this._metaOpts = getMetaSchemaOptions();
|
||||
|
||||
addInitialSchemas();
|
||||
if (opts.formats) addInitialFormats();
|
||||
addDraft4MetaSchema();
|
||||
if (opts.v5) v5.enable(this);
|
||||
if (typeof opts.meta == 'object') addMetaSchema(opts.meta);
|
||||
addInitialSchemas();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -346,13 +347,16 @@ function Ajv(opts) {
|
|||
}
|
||||
|
||||
|
||||
function addInitialSchemas() {
|
||||
function addDraft4MetaSchema() {
|
||||
if (self._opts.meta !== false) {
|
||||
var metaSchema = require('./refs/json-schema-draft-04.json');
|
||||
addMetaSchema(metaSchema, META_SCHEMA_ID, true);
|
||||
self._refs['http://json-schema.org/schema'] = META_SCHEMA_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function addInitialSchemas() {
|
||||
var optsSchemas = self._opts.schemas;
|
||||
if (!optsSchemas) return;
|
||||
if (Array.isArray(optsSchemas)) addSchema(optsSchemas);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ajv",
|
||||
"version": "4.1.0",
|
||||
"version": "4.1.1",
|
||||
"description": "Another JSON Schema Validator",
|
||||
"main": "lib/ajv.js",
|
||||
"typings": "lib/ajv.d.ts",
|
||||
|
|
Loading…
Reference in New Issue