Skip to content

Commit

Permalink
Create README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastian-toepfer authored Dec 2, 2023
1 parent 5e8d48a commit 0b817c1
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions README.md
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
}
}
```

0 comments on commit 0b817c1

Please sign in to comment.