| 1 |
JSON Schema Test Suite [](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite) |
| 2 |
====================== |
| 3 |
|
| 4 |
This repository contains a set of JSON objects that implementors of JSON Schema |
| 5 |
validation libraries can use to test their validators. |
| 6 |
|
| 7 |
It is meant to be language agnostic and should require only a JSON parser. |
| 8 |
|
| 9 |
The conversion of the JSON objects into tests within your test framework of |
| 10 |
choice is still the job of the validator implementor. |
| 11 |
|
| 12 |
Structure of a Test |
| 13 |
------------------- |
| 14 |
|
| 15 |
If you're going to use this suite, you need to know how tests are laid out. The |
| 16 |
tests are contained in the `tests` directory at the root of this repository. |
| 17 |
|
| 18 |
Inside that directory is a subdirectory for each draft or version of the |
| 19 |
schema. We'll use `draft3` as an example. |
| 20 |
|
| 21 |
If you look inside the draft directory, there are a number of `.json` files, |
| 22 |
which logically group a set of test cases together. Often the grouping is by |
| 23 |
property under test, but not always, especially within optional test files |
| 24 |
(discussed below). |
| 25 |
|
| 26 |
Inside each `.json` file is a single array containing objects. It's easiest to |
| 27 |
illustrate the structure of these with an example: |
| 28 |
|
| 29 |
```json |
| 30 |
{ |
| 31 |
"description": "the description of the test case", |
| 32 |
"schema": {"the schema that should" : "be validated against"}, |
| 33 |
"tests": [ |
| 34 |
{ |
| 35 |
"description": "a specific test of a valid instance", |
| 36 |
"data": "the instance", |
| 37 |
"valid": true |
| 38 |
}, |
| 39 |
{ |
| 40 |
"description": "another specific test this time, invalid", |
| 41 |
"data": 15, |
| 42 |
"valid": false |
| 43 |
} |
| 44 |
] |
| 45 |
} |
| 46 |
``` |
| 47 |
|
| 48 |
So a description, a schema, and some tests, where tests is an array containing |
| 49 |
one or more objects with descriptions, data, and a boolean indicating whether |
| 50 |
they should be valid or invalid. |
| 51 |
|
| 52 |
Coverage |
| 53 |
-------- |
| 54 |
|
| 55 |
Draft 3 and 4 should have full coverage. If you see anything missing or think |
| 56 |
there is a useful test missing, please send a pull request or open an issue. |
| 57 |
|
| 58 |
Who Uses the Test Suite |
| 59 |
----------------------- |
| 60 |
|
| 61 |
This suite is being used by: |
| 62 |
|
| 63 |
### Coffeescript ### |
| 64 |
|
| 65 |
* [jsck](https://github.com/pandastrike/jsck) |
| 66 |
|
| 67 |
### Dart ### |
| 68 |
|
| 69 |
* [json_schema](https://github.com/patefacio/json_schema) |
| 70 |
|
| 71 |
### Erlang ### |
| 72 |
|
| 73 |
* [jesse](https://github.com/klarna/jesse) |
| 74 |
|
| 75 |
### Go ### |
| 76 |
|
| 77 |
* [gojsonschema](https://github.com/sigu-399/gojsonschema) |
| 78 |
* [validate-json](https://github.com/cesanta/validate-json) |
| 79 |
|
| 80 |
### Haskell ### |
| 81 |
|
| 82 |
* [aeson-schema](https://github.com/timjb/aeson-schema) |
| 83 |
* [hjsonschema](https://github.com/seagreen/hjsonschema) |
| 84 |
|
| 85 |
### Java ### |
| 86 |
|
| 87 |
* [json-schema-validator](https://github.com/fge/json-schema-validator) |
| 88 |
|
| 89 |
### JavaScript ### |
| 90 |
|
| 91 |
* [json-schema-benchmark](https://github.com/Muscula/json-schema-benchmark) |
| 92 |
* [direct-schema](https://github.com/IreneKnapp/direct-schema) |
| 93 |
* [is-my-json-valid](https://github.com/mafintosh/is-my-json-valid) |
| 94 |
* [jassi](https://github.com/iclanzan/jassi) |
| 95 |
* [JaySchema](https://github.com/natesilva/jayschema) |
| 96 |
* [json-schema-valid](https://github.com/ericgj/json-schema-valid) |
| 97 |
* [Jsonary](https://github.com/jsonary-js/jsonary) |
| 98 |
* [jsonschema](https://github.com/tdegrunt/jsonschema) |
| 99 |
* [request-validator](https://github.com/bugventure/request-validator) |
| 100 |
* [skeemas](https://github.com/Prestaul/skeemas) |
| 101 |
* [tv4](https://github.com/geraintluff/tv4) |
| 102 |
* [z-schema](https://github.com/zaggino/z-schema) |
| 103 |
* [jsen](https://github.com/bugventure/jsen) |
| 104 |
* [ajv](https://github.com/epoberezkin/ajv) |
| 105 |
|
| 106 |
### Node.js ### |
| 107 |
|
| 108 |
The JSON Schema Test Suite is also available as an |
| 109 |
[npm](https://www.npmjs.com/package/json-schema-test-suite) package. |
| 110 |
Node-specific support is maintained on the [node branch](https://github.com/json-schema/JSON-Schema-Test-Suite/tree/node). |
| 111 |
See [NODE-README.md](https://github.com/json-schema/JSON-Schema-Test-Suite/blob/node/NODE-README.md) |
| 112 |
for more information. |
| 113 |
|
| 114 |
### .NET ### |
| 115 |
|
| 116 |
* [Newtonsoft.Json.Schema](https://github.com/JamesNK/Newtonsoft.Json.Schema) |
| 117 |
|
| 118 |
### PHP ### |
| 119 |
|
| 120 |
* [json-schema](https://github.com/justinrainbow/json-schema) |
| 121 |
|
| 122 |
### Python ### |
| 123 |
|
| 124 |
* [jsonschema](https://github.com/Julian/jsonschema) |
| 125 |
|
| 126 |
### Ruby ### |
| 127 |
|
| 128 |
* [json-schema](https://github.com/hoxworth/json-schema) |
| 129 |
|
| 130 |
### Rust ### |
| 131 |
|
| 132 |
* [valico](https://github.com/rustless/valico) |
| 133 |
|
| 134 |
### Swift ### |
| 135 |
|
| 136 |
* [JSONSchema](https://github.com/kylef/JSONSchema.swift) |
| 137 |
|
| 138 |
If you use it as well, please fork and send a pull request adding yourself to |
| 139 |
the list :). |
| 140 |
|
| 141 |
Contributing |
| 142 |
------------ |
| 143 |
|
| 144 |
If you see something missing or incorrect, a pull request is most welcome! |
| 145 |
|
| 146 |
There are some sanity checks in place for testing the test suite. You can run |
| 147 |
them with `bin/jsonschema_suite check` or `tox`. They will be run automatically by |
| 148 |
[Travis CI](https://travis-ci.org/) as well. |