Skip to content

Commit 2d9d5ef

Browse files
committed
add a doc for metaschema validation
1 parent a199ac6 commit 2d9d5ef

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ For the latest version, please check the [release](https://github.com/networknt/
127127

128128
## [Multiple Language](doc/multiple-language.md)
129129

130+
## [MetaSchema Validation](doc/metaschema-validation.md)
131+
130132

131133
## Known issues
132134

doc/metaschema-validation.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
If you have an use case to validate custom schemas against the one of the JSON schema draft version, here is the code that you can do it.
2+
3+
```
4+
public static final Function<ObjectNode, Set<SchemaValidationMessage>> validateAgainstMetaSchema =
5+
schema -> {
6+
JsonSchemaFactory factory = JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V201909);
7+
JsonSchema metaSchema = factory.getSchema(getSchemaUri());
8+
return metaSchema.validate(schema).stream()
9+
.map((validation) -> new SchemaValidationMessage(validation.getMessage()))
10+
.collect(Collectors.toSet());
11+
};
12+
13+
```
14+
15+
This should now work but does not support all the keywords because the JsonMetaSchema of SpecVersion.VersionFlag.V201909 is lacking these features.
16+
17+
You can fix the issue by resolving the vocabularies to a local resource file and re-do the JsonMetaSchema for 2019 based on that.
18+
19+
20+

0 commit comments

Comments
 (0)