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

$ref with spaces does not work #63

Open
EdikDolynskyi opened this issue Jan 27, 2017 · 0 comments
Open

$ref with spaces does not work #63

EdikDolynskyi opened this issue Jan 27, 2017 · 0 comments

Comments

@EdikDolynskyi
Copy link

EdikDolynskyi commented Jan 27, 2017

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.

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