Open laurie71 opened 13 years ago
Note: this is using my patch for required vs. optional; without that, there are lots more errors about missing required properties ;-)
What is your patch - you just switch that one line?
Hmm, seems I accidentally deleted my fork, which has deleted the pull request too. I'll see if I still have a working copy that I can push back up.
OK, resubmitted the commit that the test case above assumes. Sorry about that.
I added vows tests on my fork, showing this problem; see https://github.com/laurie71/json-schema/commit/0a52e1e737d4adeab0cb45739062f327dfd65257
The tests are run with 'vows test/*.js'
i think i just came across this same problem. the draft-03 schema restricts a $schema
property to only be a string and the validator expects that if the $schema
property exists on an instance then it is an object (a schema to be used to validate this instance). so if you try to validate an instance that has the draft-03 schema as it's $schema
property then the validation will fail since draft-03 says that the $schema property can only be a string. if you leave the $schema property as a uri and pass in the draft-03 schema as the 2nd param to validate
then the validator fails with the message 'Invalid schema/property definition http://json-schema.org/draft-03/schema#'
.
my current workaround is to delete the $schema
property from the instance and pass the draft-03 schema as the 2nd param to validate
validating the core schema [validate(schema)] causes validate to choke on the '$schema' instance property; [validate(schema,schema)], which should be equivalent, adds an extra 'null' entry to the result. Deleting the $schema property before validating results in a single 'null' in result.errors.
Here's my test script reproducing the problem:
and here's the result of running it: