Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clivern/decoy
🔥 JSON Schema Validation Package for Java.
https://github.com/clivern/decoy
api-validator java java-validation-framework json-schema json-schema-validator schema-validation schema-validator
Last synced: about 1 month ago
JSON representation
🔥 JSON Schema Validation Package for Java.
- Host: GitHub
- URL: https://github.com/clivern/decoy
- Owner: Clivern
- License: apache-2.0
- Created: 2019-09-22T10:47:35.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-05-29T01:47:33.000Z (7 months ago)
- Last Synced: 2024-05-29T15:38:37.213Z (7 months ago)
- Topics: api-validator, java, java-validation-framework, json-schema, json-schema-validator, schema-validation, schema-validator
- Language: Java
- Homepage:
- Size: 463 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
Decoy
JSON Schema Validation Package for Java.
Decoy is a Java implementation for the [JSON Schema Standard](https://json-schema.org/) (`draft-03`, `draft-04`, `draft-06` and `draft-07`), that will help you validate all sorts of JSON documents, whether they are configuration files or a set of data sent to a RESTful API endpoint.
## Documentation
### Installation
To add a dependency using Maven, use the following:
```xml
com.clivern
decoy
0.1.0```
To add a dependency using Gradle, use the following:
```java
dependencies {
compile 'com.clivern:decoy:0.1.0'
}
```To add a dependency using Scala SBT, use the following:
```java
libraryDependencies += "com.clivern" % "decoy" % "0.1.0"
```### Usage
First import & initialize all required classes.
```java
import com.clivern.decoy.util.FileReader;
import com.clivern.decoy.SchemaFactory;
import com.clivern.decoy.Validator;FileReader fileReader = new FileReader();
SchemaFactory schemaFactory = new SchemaFactory();
Validator validator = new Validator();
```Then validate the `JSON` string against the `JSON Schema`.
```java
import com.clivern.decoy.SchemaDraft3;// For SchemaDraft3
SchemaDraft3 schemaDraft3 = schemaFactory.unserialize(
fileReader.readFileAsString("path/to/endpoint/schema03_definition.json"),
SchemaDraft3.class
);validator.validate(schemaDraft3, "{...JSON_DATA_HERE...}"); // returns Boolean (true || false)
validator.hasErrors(); // returns Boolean (true || false)
validator.getErrors(); // returns ArrayList
``````java
import com.clivern.decoy.SchemaDraft4;// For SchemaDraft4
SchemaDraft4 schemaDraft4 = schemaFactory.unserialize(
fileReader.readFileAsString("path/to/endpoint/schema04_definition.json"),
SchemaDraft4.class
);validator.validate(schemaDraft4, "{...JSON_DATA_HERE...}"); // returns Boolean (true || false)
validator.hasErrors(); // returns Boolean (true || false)
validator.getErrors(); // returns ArrayList
``````java
import com.clivern.decoy.SchemaDraft6;// For SchemaDraft6
SchemaDraft6 schemaDraft6 = schemaFactory.unserialize(
fileReader.readFileAsString("path/to/endpoint/schema06_definition.json"),
SchemaDraft6.class
);validator.validate(schemaDraft6, "{...JSON_DATA_HERE...}"); // returns Boolean (true || false)
validator.hasErrors(); // returns Boolean (true || false)
validator.getErrors(); // returns ArrayList
``````java
import com.clivern.decoy.SchemaDraft7;// For SchemaDraft7
SchemaDraft7 schemaDraft7 = schemaFactory.unserialize(
fileReader.readFileAsString("path/to/endpoint/schema07_definition.json"),
SchemaDraft7.class
);validator.validate(schemaDraft7, "{...JSON_DATA_HERE...}"); // returns Boolean (true || false)
validator.hasErrors(); // returns Boolean (true || false)
validator.getErrors(); // returns ArrayList
```### Examples
```java
#
```## Versioning
For transparency into our release cycle and in striving to maintain backward compatibility, Decoy is maintained under the [Semantic Versioning guidelines](https://semver.org/) and release process is predictable and business-friendly.
See the [Releases section of our GitHub project](https://github.com/clivern/decoy/releases) for changelogs for each release version of Decoy. It contains summaries of the most noteworthy changes made in each release.
## Bug tracker
If you have any suggestions, bug reports, or annoyances please report them to our issue tracker at https://github.com/clivern/decoy/issues
## Security Issues
If you discover a security vulnerability within Decoy, please send an email to [[email protected]](mailto:[email protected])
## Contributing
We are an open source, community-driven project so please feel free to join us. see the [contributing guidelines](CONTRIBUTING.md) for more details.
## License
© 2019, Clivern. Released under [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
**Decoy** is authored and maintained by [@Clivern](http://github.com/clivern).