Skip to content

A language agnostic test suite for the JSON Schema specifications

License

Notifications You must be signed in to change notification settings

handrews/JSON-Schema-Test-Suite

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON Schema Test Suite

Contributor Covenant Project Status: Active – The project has reached a stable, usable state and is being actively developed. Financial Contributors on Open Collective

Build Status

This repository contains a set of JSON objects that implementors of JSON Schema validation libraries can use to test their validators.

It is meant to be language agnostic and should require only a JSON parser.

The conversion of the JSON objects into tests within your test framework of choice is still the job of the validator implementor.

Structure of a Test

The tests in this suite are contained in the tests directory at the root of this repository. Inside that directory is a subdirectory for each draft or version of the specification.

Inside each draft directory, there are a number of .json files and one or more special subdirectories. The subdirectories contain .json files meant for a specific testing purpose, and each .json file logically groups a set of test cases together. Often the grouping is by property under test, but not always.

The subdirectories are described in the next section.

Inside each .json file is a single array containing objects. It's easiest to illustrate the structure of these with an example:

{
    "description": "The description of the test case",
    "schema": {
        "description": "The schema against which the data in each test is validated",
        "type": "string"
    },
    "tests": [
        {
            "description": "Test for a valid instance",
            "data": "the instance to validate",
            "valid": true
        },
        {
            "description": "Test for an invalid instance",
            "data": 15,
            "valid": false
        }
    ]
}

In short: a description, a schema under test, and some tests, where each test in the tests array is an objects with a description of the case itself, the instance under test, and a boolean indicating whether it should be valid or invalid.

Test Subdirectories

There is currently only one subdirectory that may exist within each draft directory. This is:

  1. optional/: Contains tests that are considered optional.

Coverage

All JSON Schema specification releases should be well covered by this suite, including drafts 2020-12, 2019-09, 07, 06, 04 and 03. Additional coverage is always welcome, particularly for bugs encountered in real-world implementations.

Drafts 04 and 03 are considered "frozen" in that less effort is put in to backport new tests to these versions.

Contributions are very welcome, especially from implementers as they add support to their own implementations.

If you see anything missing from the current supported drafts, or incorrect on any draft still accepting bug fixes, please file an issue or submit a PR.

Who Uses the Test Suite

This suite is being used by:

Clojure

Coffeescript

Common Lisp

C++

Dart

Elixir

Erlang

Go

Haskell

Java

JavaScript

Node.js

For node.js developers, the suite is also available as an npm package.

Node-specific support is maintained in a separate repository which also welcomes your contributions!

.NET

Perl

PHP

PostgreSQL

Python

Ruby

Rust

Scala

Swift

If you use it as well, please fork and send a pull request adding yourself to the list :).

Contributing

If you see something missing or incorrect, a pull request is most welcome!

There are some sanity checks in place for testing the test suite. You can run them with bin/jsonschema_suite check or tox. They will be run automatically by GitHub Actions as well.

About

A language agnostic test suite for the JSON Schema specifications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Python 100.0%