removed unused code
parent
f19f7fdedf
commit
0576ea986e
|
@ -23,7 +23,6 @@ function Ajv(opts) {
|
||||||
this.opts = opts || {};
|
this.opts = opts || {};
|
||||||
this._schemas = {};
|
this._schemas = {};
|
||||||
this._refs = {};
|
this._refs = {};
|
||||||
this._missing = {};
|
|
||||||
this._byJson = {};
|
this._byJson = {};
|
||||||
this._formats = formats(this.opts.format);
|
this._formats = formats(this.opts.format);
|
||||||
|
|
||||||
|
@ -165,8 +164,7 @@ function Ajv(opts) {
|
||||||
|
|
||||||
|
|
||||||
function checkUnique(id) {
|
function checkUnique(id) {
|
||||||
var schemaRef = self._refs[id];
|
if (self._schemas[id] || self._refs[id])
|
||||||
if (self._schemas[id] || (schemaRef && !schemaRef.missing))
|
|
||||||
throw new Error('schema with key or id "' + id + '" already exists');
|
throw new Error('schema with key or id "' + id + '" already exists');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@ resolve.normalizeId = normalizeId;
|
||||||
resolve.fullPath = getFullPath;
|
resolve.fullPath = getFullPath;
|
||||||
resolve.url = resolveUrl;
|
resolve.url = resolveUrl;
|
||||||
resolve.ids = resolveIds;
|
resolve.ids = resolveIds;
|
||||||
resolve.missing = resolveMissing;
|
|
||||||
|
|
||||||
|
|
||||||
function resolve(compile, root, ref) {
|
function resolve(compile, root, ref) {
|
||||||
|
@ -37,13 +36,8 @@ function _resolve(root, ref) {
|
||||||
, refPath = _getFullPath(p)
|
, refPath = _getFullPath(p)
|
||||||
, baseId = getFullPath(root.schema.id);
|
, baseId = getFullPath(root.schema.id);
|
||||||
if (refPath !== baseId) {
|
if (refPath !== baseId) {
|
||||||
// rootSchema = undefined; TODO this breaks resolution in meta-schema
|
|
||||||
var refVal = this._refs[refPath];
|
var refVal = this._refs[refPath];
|
||||||
if (typeof refVal == 'string') refVal = this._refs[refVal];
|
if (typeof refVal == 'string') refVal = this._refs[refVal];
|
||||||
// {
|
|
||||||
// if (this._refs[refVal]) refVal = this._refs[refVal];
|
|
||||||
// else refVal = resolve.call(this, rootSchema, refVal);
|
|
||||||
// }
|
|
||||||
if (typeof refVal == 'function') util.copy(refVal, root);
|
if (typeof refVal == 'function') util.copy(refVal, root);
|
||||||
else {
|
else {
|
||||||
var id = normalizeId(refPath);
|
var id = normalizeId(refPath);
|
||||||
|
@ -56,9 +50,14 @@ function _resolve(root, ref) {
|
||||||
if (!root.schema) return;
|
if (!root.schema) return;
|
||||||
baseId = getFullPath(root.schema.id);
|
baseId = getFullPath(root.schema.id);
|
||||||
}
|
}
|
||||||
p.hash = p.hash || '';
|
return getJsonPointer.call(this, p, baseId, root);
|
||||||
if (p.hash.slice(0,2) != '#/') return;
|
}
|
||||||
var parts = p.hash.split('/');
|
|
||||||
|
|
||||||
|
function getJsonPointer(parsedRef, baseId, root) {
|
||||||
|
parsedRef.hash = parsedRef.hash || '';
|
||||||
|
if (parsedRef.hash.slice(0,2) != '#/') return;
|
||||||
|
var parts = parsedRef.hash.split('/');
|
||||||
var schema = root.schema;
|
var schema = root.schema;
|
||||||
|
|
||||||
for (var i = 1; i < parts.length; i++) {
|
for (var i = 1; i < parts.length; i++) {
|
||||||
|
@ -138,16 +137,8 @@ function _resolveIds(schema, fullPath, baseId) {
|
||||||
throw new Error('id "' + id + '" resolves to more than one schema');
|
throw new Error('id "' + id + '" resolves to more than one schema');
|
||||||
} else if (id != normalizeId(fullPath))
|
} else if (id != normalizeId(fullPath))
|
||||||
this._refs[id] = fullPath;
|
this._refs[id] = fullPath;
|
||||||
|
|
||||||
// TODO check and resolve missing
|
|
||||||
|
|
||||||
}
|
}
|
||||||
for (var key in schema)
|
for (var key in schema)
|
||||||
_resolveIds.call(this, schema[key], fullPath+'/'+escapeFragment(key), baseId);
|
_resolveIds.call(this, schema[key], fullPath+'/'+escapeFragment(key), baseId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function resolveMissing(schema, schemaRef) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ajv",
|
"name": "ajv",
|
||||||
"version": "0.4.12",
|
"version": "0.4.14",
|
||||||
"description": "Another JSON schema Validator",
|
"description": "Another JSON schema Validator",
|
||||||
"main": "lib/ajv.js",
|
"main": "lib/ajv.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue