Re: [json-schema-validator] Setting draft v3 in 2.2.5?

67 views
Skip to first unread message

Francis Galiegue

unread,
Jun 2, 2014, 11:18:25 AM6/2/14
to makefile, json-schem...@googlegroups.com
Hello,

On Mon, Jun 2, 2014 at 4:59 PM, makefile <gwal...@gmail.com> wrote:
> I read something about the validator defaulting to draft v4 for schema
> validation. Is this true? If so, can I set it to work with draft v3?
>

This is true. In order to work with draft v3 you can do one of two things:

* set the $schema appropriately in your schema(s) since the library
detects that;
* configure the JsonSchemaFactory so that the default version used is draft v3.

For the latter, you need to customize your validation configuration:

final ValidationConfiguration cfg = ValidationConfiguration.newBuilder()
.setDefaultVersion(SchemaVersion.DRAFT_V3).freeze();

final JsonSchemaFactory factory = JsonSchemaFactory.newBuilder()
.setValidationConfiguration(cfg).freeze();

However, defining $schema is preferred; this is a better choice for
interoperability purposes.

Hopes this helps,
--
Francis Galiegue, fgal...@gmail.com, https://github.com/fge
JSON Schema in Java: http://json-schema-validator.herokuapp.com
Parsers in pure Java: https://github.com/parboiled1/grappa (redde
Caesaris: https://github.com/sirthias)

makefile

unread,
Jun 2, 2014, 11:32:17 AM6/2/14
to json-schem...@googlegroups.com, gwal...@gmail.com
Alright, I figured this was the case. I went ahead and defined the $schema to use v3 and it is working again. We will have to update our schema in the future to draft v4. Thanks for the quick response!
Reply all
Reply to author
Forward
0 new messages