Created
November 1, 2013 18:48
-
-
Save mwmitchell/7270012 to your computer and use it in GitHub Desktop.
boiler plate code for validation using custom ref path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import '[com.github.fge.jsonschema.main JsonSchemaFactory]) | |
(import '[com.github.fge.jackson JsonLoader]) | |
(import '[com.github.fge.jsonschema.load.configuration LoadingConfiguration]) | |
(import '[com.github.fge.jsonschema.load Dereferencing]) | |
(import '[com.fasterxml.jackson.databind.node ObjectNode]) | |
(let [cfg (.dereferencing | |
(.setNamespace | |
(LoadingConfiguration/newBuilder) | |
"resource:///schema-file-dir-on-classpath/") | |
Dereferencing/CANONICAL) | |
obj (JsonLoader/fromResource "/schema-file-dir-on-classpath/my-schema.json") | |
f (JsonSchemaFactory/newBuilder) | |
_ (.setLoadingConfiguration f (.freeze cfg)) | |
schema (.getJsonSchema (.freeze f) obj)] | |
(.asJson (.validateUnchecked schema (ObjectNode. nil)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment