|
| 1 | +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 your test framework of choice (say, |
| 10 | +an `xUnit`) 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. |
| 23 | + |
| 24 | +Inside each `.json` file is a single array containing objects. It's easiest to |
| 25 | +illustrate the structure of these with an example: |
| 26 | + |
| 27 | + { |
| 28 | + "description": "the description of the test case", |
| 29 | + "schema": "the schema that should be validated against", |
| 30 | + "tests": [ |
| 31 | + { |
| 32 | + "description": "a specific test of a valid instance", |
| 33 | + "data": "the instance", |
| 34 | + "valid": true |
| 35 | + }, |
| 36 | + { |
| 37 | + "description": "another specific test this time, invalid", |
| 38 | + "data": 15, |
| 39 | + "valid": false |
| 40 | + }, |
| 41 | + ] |
| 42 | + } |
| 43 | + |
| 44 | +So a description, a schema, and some tests, where tests is an array containing |
| 45 | +one or more objects with descriptions, data, and a boolean indicating whether |
| 46 | +they should be valid or invalid. |
| 47 | + |
| 48 | +Coverage |
| 49 | +-------- |
| 50 | + |
| 51 | +The coverage of this suite is actively growing. The first order of business is |
| 52 | +to have a full-coverage draft 3 test suite. |
| 53 | + |
| 54 | +Ultimately, when it's done, the idea is to attempt to have it included on [the |
| 55 | +JSON Schema website](http://www.json-schema.org). |
| 56 | + |
| 57 | +Contributing |
| 58 | +------------ |
| 59 | + |
| 60 | +I need help! If you'd like to contribute, please fork this repository. I'd love |
| 61 | +to have your pull requests sent over. |
| 62 | + |
| 63 | +Right now, the way I'm compiling the tests is by porting over a test suite |
| 64 | +that I'd written for a Python validator. The tests (in a messy format) can be |
| 65 | +found [here](https://github.com/Julian/jsonschema/blob/master/tests.py#L100). |
| 66 | + |
| 67 | +There are also other JSON Schema test suites for various other validators, and |
| 68 | +it would certainly be nice to merge all of them as well. In particular, [this |
| 69 | +validator](https://github.com/fge/json-schema-validator/tree/master/src/test/resources/keyword) |
| 70 | +contains a set of tests already written in JSON which will be useful. |
0 commit comments