Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vietj/vertx-json-schema
https://github.com/vietj/vertx-json-schema
Last synced: 20 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/vietj/vertx-json-schema
- Owner: vietj
- License: apache-2.0
- Created: 2019-05-02T14:32:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-10T09:42:43.000Z (about 5 years ago)
- Last Synced: 2024-11-08T20:49:59.355Z (2 months ago)
- Language: Java
- Size: 140 KB
- Stars: 0
- Watchers: 14
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
## Vert.x JSON Schema
[![Build Status](https://travis-ci.org/vert-x3/vertx-json-schema.svg?branch=master)](https://travis-ci.org/vert-x3/vertx-json-schema)
## Architecture
* `SchemaParser`: Parses the schemas. It can be used to parse various schemas. Every JSON Schema dialect/version has one
* `SchemaRouter`: Contains a cache of parsed schemas and resolve cached/local/external `$ref`. You can share it across various `SchemaParser`
* `Validator`: Contains validation logic for single/multiple keyword(s)
* `Schema`: Represents a schema and contains `Validator` instances
* `ValidatorFactory`: Represents a factory for a `Validator`## How to use
````java
SchemaRouter router = SchemaRouter.create(vertx)
SchemaParserOptions options = new SchemaParserOptions();
SchemaParser parser = Draft7SchemaParser.create(options, router);
Schema schema = parser.parse(schema, scope);
Future validationResult = schema.validateAsync(objectToValidate);
````Or shorthand
```java
Schema schema = Draft7SchemaParser.parse(vertx, schema, scope);
Future validationResult = schema.validateAsync(objectToValidate);
```## Extend the validator
To support custom keywords, you can create a new `ValidatorFactory` and register to a `SchemaParser` with `SchemaParserOptions.putAdditionalValidatorFactory()`