You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a Java implementation of the [JSON Schema Core Draft v4, v6, v7, v2019-09 and v2020-12](http://json-schema.org/latest/json-schema-core.html) specification for JSON schema validation.
14
+
This is a Java implementation of the [JSON Schema Core Draft v4, v6, v7, v2019-09 and v2020-12](http://json-schema.org/latest/json-schema-core.html) specification for JSON schema validation. This implementation supports [Customizing Meta-Schemas, Vocabularies, Keywords and Formats](doc/custom-meta-schema.md).
15
15
16
16
In addition, it also works for OpenAPI 3.0 request/response validation with some [configuration flags](doc/config.md). For users who want to collect information from a JSON node based on the schema, the [walkers](doc/walkers.md) can help. The JSON parser used is the [Jackson](https://github.com/FasterXML/jackson) parser. As it is a key component in our [light-4j](https://github.com/networknt/light-4j) microservices framework to validate request/response against OpenAPI specification for [light-rest-4j](http://www.networknt.com/style/light-rest-4j/) and RPC schema for [light-hybrid-4j](http://www.networknt.com/style/light-hybrid-4j/) at runtime, performance is the most important aspect in the design.
Information on the compatibility support for each version, including known issues, can be found in the [Compatibility with JSON Schema versions](doc/compatibility.md) document.
21
28
22
29
Since [Draft 2019-09](https://json-schema.org/draft/2019-09/json-schema-validation#rfc.section.7) the `format` keyword only generates annotations by default and does not generate assertions.
@@ -214,15 +221,15 @@ This package is available on Maven central.
The following example demonstrates how a schema is validated against a meta-schema.
275
284
276
-
The following example demonstrates how a schema is validated against a meta schema.
285
+
This is actually the same as validating inputs against a schema except in this case the input is the schema and the schema used is the meta-schema.
277
286
278
-
This is actually the same as validating inputs against a schema except in this case the input is the schema and the schema used is the meta schema.
287
+
Note that the meta-schemas for Draft 4, Draft 6, Draft 7, Draft 2019-09 and Draft 2020-12 are bundled with the library and these classpath resources will be used by default.
// By default since Draft 2019-09 the format keyword only generates annotations and not assertions
@@ -319,7 +320,7 @@ The following types of results are generated by the library.
319
320
320
321
| Type | Description
321
322
|-------------|-------------------
322
-
| Assertions | Validation errors generated by a keyword on a particular input data instance. This is generally described in a `ValidationMessage` or in a `OutputUnit`. Note that since Draft 2019-09 the `format` keyword no longer generates assertions by default and instead generates only annotations unless configured otherwise using a configuration option or by using a metaschema that uses the appropriate vocabulary.
323
+
| Assertions | Validation errors generated by a keyword on a particular input data instance. This is generally described in a `ValidationMessage` or in a `OutputUnit`. Note that since Draft 2019-09 the `format` keyword no longer generates assertions by default and instead generates only annotations unless configured otherwise using a configuration option or by using a meta-schema that uses the appropriate vocabulary.
323
324
| Annotations | Additional information generated by a keyword for a particular input data instance. This is generally described in a `OutputUnit`. Annotation collection and reporting is turned off by default. Annotations required by keywords such as `unevaluatedProperties` or `unevaluatedItems` are always collected for evaluation purposes and cannot be disabled but will not be reported unless configured to do so.
324
325
325
326
The following information is used to describe both types of results.
The earlier draft specifications contain less keywords that can potentially impact performance. For instance the use of the `unevaluatedProperties` or `unevaluatedItems` keyword will trigger annotation collection in the related validators, such as the `properties` or `items` validators.
485
486
486
-
This does not mean that using a schema with a later draft specification will automatically cause a performance impact. For instance, the `properties` validator will perform checks to determine if annotations need to be collected, and checks if the metaschema contains the `unevaluatedProperties` keyword and whether the `unevaluatedProperties` keyword exists adjacent the evaluation path.
487
+
This does not mean that using a schema with a later draft specification will automatically cause a performance impact. For instance, the `properties` validator will perform checks to determine if annotations need to be collected, and checks if the meta-schema contains the `unevaluatedProperties` keyword and whether the `unevaluatedProperties` keyword exists adjacent the evaluation path.
The `pattern` validator by default uses the JDK regular expression implementation which is not ECMA-262 compliant and is thus not compliant with the JSON Schema specification. The library can however be configured to use a ECMA-262 compliant regular expression implementation.
4
11
5
12
Annotation processing and reporting are implemented. Note that the collection of annotations will have an adverse performance impact.
6
13
7
14
This implements the Flag, List and Hierarchical output formats defined in the [Specification for Machine-Readable Output for JSON Schema Validation and Annotation](https://github.com/json-schema-org/json-schema-spec/blob/8270653a9f59fadd2df0d789f22d486254505bbe/jsonschema-validation-output-machines.md).
8
15
16
+
The implementation supports the use of custom keywords, formats, vocabularies and meta-schemas.
17
+
9
18
### Known Issues
10
19
11
20
There are currently no known issues with the required functionality from the specification.
@@ -84,6 +93,8 @@ The following are the tests results after running the [JSON Schema Test Suite](h
84
93
| uniqueItems | 🟢 | 🟢 | 🟢 | 🟢 | 🟢 |
85
94
| writeOnly | 🚫 | 🚫 | 🟢 | 🟢 | 🟢 |
86
95
96
+
In accordance with the specification, unknown keywords are treated as annotations. This is customizable by configuring a unknown keyword factory on the respective meta-schema.
97
+
87
98
#### Content Encoding
88
99
89
100
Since Draft 2019-09, the `contentEncoding` keyword does not generate assertions.
@@ -156,6 +167,4 @@ When the format assertion vocabularies are used in a meta schema, in accordance
156
167
157
168
##### Footnotes
158
169
1. Note that the validation are only optional for some of the keywords/formats.
159
-
2. Refer to the corresponding JSON schema for more information on whether the keyword/format is optional or not.
160
-
161
-
170
+
2. Refer to the corresponding JSON schema for more information on whether the keyword/format is optional or not.
0 commit comments