How to validate not an instance, but a schema?

391 views
Skip to first unread message

Matt Mitchell

unread,
Nov 1, 2013, 12:56:32 PM11/1/13
to json-schem...@googlegroups.com
Hi. When my app starts up, I'd like to make sure that all of the schemas I'm going to use are valid. Before performing any object instance validation, I'd like to know about JSON syntax errors, bad $refs and un-recognized keywords. I thought using the unchecked, "deep" validation [1] might work - only paying attention to "fatal" errors in the result, but there isn't a maven release that has the new "deep" validation code.

Any ideas?

Thanks,
- Matt

Francis Galiegue

unread,
Feb 8, 2014, 7:37:47 AM2/8/14
to Matt Mitchell, json-schem...@googlegroups.com
Hello,

On Fri, Nov 1, 2013 at 5:56 PM, Matt Mitchell <good...@gmail.com> wrote:
> Hi. When my app starts up, I'd like to make sure that all of the schemas I'm
> going to use are valid. Before performing any object instance validation,
> I'd like to know about JSON syntax errors, bad $refs and un-recognized
> keywords. I thought using the unchecked, "deep" validation [1] might work -
> only paying attention to "fatal" errors in the result, but there isn't a
> maven release that has the new "deep" validation code.
>
> Any ideas?
>

Which version are you using?

One solution is to validate against the metaschema itself
(http://json-schema.org/draftv4/json-schema#), but there are other
methods (depending on the version you use) which validate further.

--
Francis Galiegue, fgal...@gmail.com
JSON Schema in Java: http://json-schema-validator.herokuapp.com

Christopher Fenner

unread,
May 6, 2015, 11:56:47 AM5/6/15
to json-schem...@googlegroups.com, good...@gmail.com
Hey there, I'm having the same requirement right now. I'm using v2.2.6, what are these other solutions? Where can I get the metaschema?

regards chris

Christopher Fenner

unread,
May 11, 2015, 10:14:07 AM5/11/15
to json-schem...@googlegroups.com, good...@gmail.com
Ok, the metaschema is now under http://json-schema.org/draft-04/schema# but the validation against it is not very useful. Unknown keywords or unresolveable referencen are not found but exist.

Clemens Uhlenhut

unread,
May 11, 2015, 2:10:16 PM5/11/15
to json-schem...@googlegroups.com, good...@gmail.com
Hi,

but you can get a report about unknown keywords also from the Java JSON schema validator. I get them in XML ValidatorBuddy as warnings:

In the JSON editor I take a look at the com/github/fge/jsonschema/core/report/ProcessingReport object returned by the com/github/fge/jsonschema/main/JsonValidator/validate() method. In case of unknown keywords the log-level of those messages is "warning".

Hope this helps
Clemens 

Clemens Uhlenhut

unread,
May 11, 2015, 2:33:28 PM5/11/15
to json-schem...@googlegroups.com, good...@gmail.com
Small correction: I'm using the validateSchema() method from the com/github/fge/jsonschema/processors/syntax/SyntaxValidator class to validate the JSON schema...

Clemens

Christopher Fenner

unread,
May 12, 2015, 9:33:25 AM5/12/15
to json-schem...@googlegroups.com, good...@gmail.com
Thank you, that helped a lot.
Reply all
Reply to author
Forward
0 new messages