-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
json-schema 2.0.1 broke schema validation #58
Comments
The major version change from 1.x to 2.x was made due to the breaking changes introduced in JSON Schema Draft-04 with respect to a number of properties. Since Draft-04 is final, this library now uses it as the default validator when the specific version is not specified. The usage of the Draft-03 support is still provided, so existing schemas can validate against Draft-03 through a variety of methods. The simplest and most portable way of doing this is to use the PAGE_SCHEMA <<-END_SCHEMA
{
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "object",
"title": "page",
...
}
END_SCHEMA Alternatively, you can specify the draft-03 validator from the validation call, if you cannot or do not want to edit your schema itself. JSON::Validator.validate(schema, data, :version => :draft3) I know this is a frustrating change, and I'm not exactly sure what the right approach is to ensure backwards compatibility. My supposition is that since JSON Schema is still in draft 4 and is (slowly) changing, the best we can do with this library is give users the ability to lock to specific schema versions while updating the major version number whenever a new breaking change occurs in a published draft. For reference, the following link outlines changes from draft-03 to draft-04, if you are interested in some of the updates: https://github.com/json-schema/json-schema/wiki/ChangeLog. |
Closing this until a failure case can be presented with respect to schema versions. |
The full validation broke with v2.0.1 when it was fine with v2.0.0, for example:
The validation error reads: "JSON::Schema::ValidationError: The property '#/properties/page/required' of type TrueClass did not match the following type: array in schema http://json-schema.org/draft-04/schema#"
This can't be right for a "required" property, surely?
The text was updated successfully, but these errors were encountered: