-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5e8d48a
commit 0b817c1
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# json-schema | ||
json schema for json-api | ||
|
||
## maven dependency | ||
|
||
```xml | ||
<!-- api only --> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>json-schema-api</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
</dependency> | ||
<!-- default impl. --> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>json-schema-core</artifactId> | ||
<version>0.1.0-SNAPSHOT</version> | ||
</dependency> | ||
``` | ||
|
||
## create a jsonschema instance | ||
```java | ||
final JsonSchema schema = JsonSchemas.load("{}"); | ||
``` | ||
|
||
## validate a json instance againts a schema | ||
```java | ||
if (schema.validator().isValid("{}")) { | ||
processJson("{}"); | ||
} else { | ||
throws new IllegalArgumentException("Json is not valid"); | ||
} | ||
``` | ||
|
||
## extend with own keywords (define a vocabulary) | ||
|
||
Provide a service of type `io.github.sebastiantoepfer.jsonschema.vocabulary.spi.LazyVocabularies` | ||
Provide a implemention of type `io.github.sebastiantoepfer.jsonschema.Vocabulary` | ||
|
||
To use your new Vocabulary put it into the classpath define it in the schema: | ||
``` | ||
{ | ||
$vocabulary: { | ||
"<id of your vocabulars>": true //or false if is not required -> means validtion works also if it is not in classpath | ||
} | ||
} | ||
``` |