You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@johnzon.apache.org by Romain Manni-Bucau <rm...@gmail.com> on 2018/04/28 07:48:58 UTC

Jsonschema module

Hi guys

Id like to add a jsonschema module supporting the representation and
validation of an object from a schema.

Wdyt? It would be jsonp based i think.

Re: Jsonschema module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Pushed all I had in mind, it misses a few validations like: dependencies,
allOf, formats but the main things are here (sizes, pattern, structures,
etc...)

Feel free to hack it and, add what is missing (code shouldn't be that hard
I hope) or let me know if there is any issue with that module. I'll add a
word on it in the doc right now.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-04-29 20:12 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:

> Hi guys,
>
> started to add it through https://github.com/apache/johnzon/commit/
> 947c91b8a6b17d87b464a8a87423ea7b577d27f7 (I'll continue later tonight or
> tomorrow probably)
>
> Let me know if there is any issue, high level the usage is:
>
> JsonObject schema = getJsonSchema();
> JsonObject objectToValidateAgainstSchema = getObject();
> JsonSchemaValidatorFactory factory = new JsonSchemaValidatorFactory();
> JsonSchemaValidator validator = factory.newInstance(schema);
> // runtime starts here
> ValidatinResult result = validator.apply(objectToValidateAgainstSchema);
> // if result.isSuccess, result.getErrors etc...
> // end of runtime
> validator.close();
> factory.close();
>
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://rmannibucau.metawerx.net/> | Old Blog
> <http://rmannibucau.wordpress.com> | Github
> <https://github.com/rmannibucau> | LinkedIn
> <https://www.linkedin.com/in/rmannibucau> | Book
> <https://www.packtpub.com/application-development/java-ee-8-high-performance>
>
> 2018-04-28 9:48 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:
>
>> Hi guys
>>
>> Id like to add a jsonschema module supporting the representation and
>> validation of an object from a schema.
>>
>> Wdyt? It would be jsonp based i think.
>>
>
>

Re: Jsonschema module

Posted by Romain Manni-Bucau <rm...@gmail.com>.
Hi guys,

started to add it through
https://github.com/apache/johnzon/commit/947c91b8a6b17d87b464a8a87423ea7b577d27f7
(I'll continue later tonight or tomorrow probably)

Let me know if there is any issue, high level the usage is:

JsonObject schema = getJsonSchema();
JsonObject objectToValidateAgainstSchema = getObject();
JsonSchemaValidatorFactory factory = new JsonSchemaValidatorFactory();
JsonSchemaValidator validator = factory.newInstance(schema);
// runtime starts here
ValidatinResult result = validator.apply(objectToValidateAgainstSchema);
// if result.isSuccess, result.getErrors etc...
// end of runtime
validator.close();
factory.close();



Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<https://rmannibucau.metawerx.net/> | Old Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Book
<https://www.packtpub.com/application-development/java-ee-8-high-performance>

2018-04-28 9:48 GMT+02:00 Romain Manni-Bucau <rm...@gmail.com>:

> Hi guys
>
> Id like to add a jsonschema module supporting the representation and
> validation of an object from a schema.
>
> Wdyt? It would be jsonp based i think.
>