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

schemaPath in error in referenced schema depends on the reference #273

Closed
epoberezkin opened this issue Aug 13, 2016 · 0 comments
Closed

Comments

@epoberezkin
Copy link
Member

JSON Schema (please make it as small as possible to reproduce the issue):

{
  "properties": {
    "a": { "$ref": "int" }
  }  
}

int:

{
  "id": "int",
  "type": "integer"
}

Data (please make it as small as posssible to reproduce the issue):

{ "a": "foo" }

Your code (please use options, schema and data as variables):

ajv.addSchema({
  "id": "int",
  "type": "integer"
});

var validate = ajv.compile({
  "properties": {
    "a": { "$ref": "int" }
  }  
});

validate(data);

See code

Validation result, data AFTER validation, error messages:

Result: false

errors:

[{
  "keyword":"type",
  "dataPath":".a",
  "schemaPath":"int/type",
  "params":{"type":"integer"},
  "message":"should be integer"}
]

What results did you expect?

schemaPath should be "int#/type" (if parent schema has {$ref:'int#'} it will be as it should).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant