Validation doesn't work if the reference path $ref has spaces, e.g. "#/definitions/some name".
Here is the next part of the code:
SchemaRegistry._resolveJsonPointer = function(schema, jp) {
if (jp === '#') {
return schema;
}
if (jp.slice(0, 2) !== '#/') {
// not a JSON pointer fragment
// (may be a valid id ref, but that’s not our problem here)
return null;
}
var path = jp.slice(2).split('/');
var currentSchema = schema;
while (path.length) {
var element = SchemaRegistry._decodeJsonPointer(path.shift());
if (!Object.prototype.hasOwnProperty.call(currentSchema, element)) {
return null;
}
currentSchema = currentSchema[element];
}
return currentSchema;
};
If the $ref has spaces, second param jp in the function is "#/definitions/some%20name".
As a result, local definition can`t be founded.
It would be nice if the author took the time to fix it.
Validation doesn't work if the reference path
$ref
has spaces, e.g."#/definitions/some name"
. Here is the next part of the code:If the
$ref
has spaces, second paramjp
in the function is"#/definitions/some%20name"
. As a result, local definition can`t be founded. It would be nice if the author took the time to fix it.