You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@johnzon.apache.org by rm...@apache.org on 2018/04/30 07:34:09 UTC
[2/2] johnzon git commit: doc for jsonschema module
doc for jsonschema module
Project: http://git-wip-us.apache.org/repos/asf/johnzon/repo
Commit: http://git-wip-us.apache.org/repos/asf/johnzon/commit/d8abbf0c
Tree: http://git-wip-us.apache.org/repos/asf/johnzon/tree/d8abbf0c
Diff: http://git-wip-us.apache.org/repos/asf/johnzon/diff/d8abbf0c
Branch: refs/heads/master
Commit: d8abbf0c02463d3a01292acda16b3b44d6aee9cb
Parents: 94a2179
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Mon Apr 30 09:33:59 2018 +0200
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Mon Apr 30 09:33:59 2018 +0200
----------------------------------------------------------------------
src/site/markdown/index.md | 37 ++++++++++++++++++++++++++++++++++++-
1 file changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/johnzon/blob/d8abbf0c/src/site/markdown/index.md
----------------------------------------------------------------------
diff --git a/src/site/markdown/index.md b/src/site/markdown/index.md
index 61da87c..eafd6e9 100644
--- a/src/site/markdown/index.md
+++ b/src/site/markdown/index.md
@@ -437,4 +437,39 @@ bind the corresponding serializer and/or deserializer:
@JsonbTypeSerializer(Polymorphic.Serializer.class)
@JsonbTypeDeserializer(Polymorphic.DeSerializer.class)
public List<Root> roots;
- }
\ No newline at end of file
+ }
+
+
+### JSON Schema
+
+<pre class="prettyprint linenums"><![CDATA[
+<dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-jsonschema</artifactId>
+ <version>${johnzon.version}</version>
+</dependency>
+]]></pre>
+
+This module provides a way to validate an instance against a [JSON Schema](http://json-schema.org/).
+
+
+<pre class="prettyprint linenums"><![CDATA[
+// long live instances (@ApplicationScoped/@Singleton)
+JsonObject schema = getJsonSchema();
+JsonSchemaValidatorFactory factory = new JsonSchemaValidatorFactory();
+JsonSchemaValidator validator = factory.newInstance(schema);
+
+// runtime starts here
+JsonObject objectToValidateAgainstSchema = getObject();
+ValidatinResult result = validator.apply(objectToValidateAgainstSchema);
+// if result.isSuccess, result.getErrors etc...
+
+// end of runtime
+validator.close();
+factory.close();
+]]></pre>
+
+Known limitations are (feel free to do a PR on github to add these missing features):
+
+* Doesn't support references in the schema
+* Doesn't support: dependencies, propertyNames, if/then/else, allOf/anyOf/oneOf/not, format validations