|
Packit |
534379 |
JSON Schema Test Suite [![Build Status](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite.png?branch=develop)](https://travis-ci.org/json-schema/JSON-Schema-Test-Suite)
|
|
Packit |
534379 |
======================
|
|
Packit |
534379 |
|
|
Packit |
534379 |
This repository contains a set of JSON objects that implementors of JSON Schema
|
|
Packit |
534379 |
validation libraries can use to test their validators.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
It is meant to be language agnostic and should require only a JSON parser.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
The conversion of the JSON objects into tests within your test framework of
|
|
Packit |
534379 |
choice is still the job of the validator implementor.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Structure of a Test
|
|
Packit |
534379 |
-------------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
If you're going to use this suite, you need to know how tests are laid out. The
|
|
Packit |
534379 |
tests are contained in the `tests` directory at the root of this repository.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Inside that directory is a subdirectory for each draft or version of the
|
|
Packit |
534379 |
schema. We'll use `draft3` as an example.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
If you look inside the draft directory, there are a number of `.json` files,
|
|
Packit |
534379 |
which logically group a set of test cases together. Often the grouping is by
|
|
Packit |
534379 |
property under test, but not always, especially within optional test files
|
|
Packit |
534379 |
(discussed below).
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Inside each `.json` file is a single array containing objects. It's easiest to
|
|
Packit |
534379 |
illustrate the structure of these with an example:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
```json
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
"description": "the description of the test case",
|
|
Packit |
534379 |
"schema": {"the schema that should" : "be validated against"},
|
|
Packit |
534379 |
"tests": [
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
"description": "a specific test of a valid instance",
|
|
Packit |
534379 |
"data": "the instance",
|
|
Packit |
534379 |
"valid": true
|
|
Packit |
534379 |
},
|
|
Packit |
534379 |
{
|
|
Packit |
534379 |
"description": "another specific test this time, invalid",
|
|
Packit |
534379 |
"data": 15,
|
|
Packit |
534379 |
"valid": false
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
]
|
|
Packit |
534379 |
}
|
|
Packit |
534379 |
```
|
|
Packit |
534379 |
|
|
Packit |
534379 |
So a description, a schema, and some tests, where tests is an array containing
|
|
Packit |
534379 |
one or more objects with descriptions, data, and a boolean indicating whether
|
|
Packit |
534379 |
they should be valid or invalid.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Coverage
|
|
Packit |
534379 |
--------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Draft 3 and 4 should have full coverage. If you see anything missing or think
|
|
Packit |
534379 |
there is a useful test missing, please send a pull request or open an issue.
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Who Uses the Test Suite
|
|
Packit |
534379 |
-----------------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
This suite is being used by:
|
|
Packit |
534379 |
|
|
Packit |
534379 |
* [json-schema-validator (Java)](https://github.com/fge/json-schema-validator)
|
|
Packit |
534379 |
* [jsonschema (python)](https://github.com/Julian/jsonschema)
|
|
Packit |
534379 |
* [aeson-schema (haskell)](https://github.com/timjb/aeson-schema)
|
|
Packit |
534379 |
* [direct-schema (javascript)](https://github.com/IreneKnapp/direct-schema)
|
|
Packit |
534379 |
* [jsonschema (javascript)](https://github.com/tdegrunt/jsonschema)
|
|
Packit |
534379 |
* [JaySchema (javascript)](https://github.com/natesilva/jayschema)
|
|
Packit |
534379 |
* [z-schema (javascript)](https://github.com/zaggino/z-schema)
|
|
Packit |
534379 |
* [jesse (Erlang)](https://github.com/klarna/jesse)
|
|
Packit |
534379 |
* [json-schema (PHP)](https://github.com/justinrainbow/json-schema)
|
|
Packit |
534379 |
* [gojsonschema (Go)](https://github.com/sigu-399/gojsonschema)
|
|
Packit |
534379 |
* [json_schema (Dart)](https://github.com/patefacio/json_schema)
|
|
Packit |
534379 |
|
|
Packit |
534379 |
If you use it as well, please fork and send a pull request adding yourself to
|
|
Packit |
534379 |
the list :).
|
|
Packit |
534379 |
|
|
Packit |
534379 |
Contributing
|
|
Packit |
534379 |
------------
|
|
Packit |
534379 |
|
|
Packit |
534379 |
If you see something missing or incorrect, a pull request is most welcome!
|