Git Product home page Git Product logo

json-schema-test-suite's Introduction

JSON Schema Test Suite

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 your test framework of choice (say, an xUnit) is still the job of the validator implementor.

Structure of a Test

If you're going to use this suite, you need to know how tests are laid out. The tests 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 schema. We'll use draft3 as an example.

If you look inside the draft directory, there are a number of .json files, which logically group a set of test cases together.

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": "the schema that should be validated against",
    "tests": [
        {
            "description": "a specific test of a valid instance",
            "data": "the instance",
            "valid": true
        },
        {
            "description": "another specific test this time, invalid",
            "data": 15,
            "valid": false
        },
    ]
}

So a description, a schema, and some tests, where tests is an array containing one or more objects with descriptions, data, and a boolean indicating whether they should be valid or invalid.

Coverage

The coverage of this suite is actively growing. The first order of business is to have a full-coverage draft 3 test suite.

Ultimately, when it's done, the idea is to attempt to have it included on the JSON Schema website.

Contributing

I need help! If you'd like to contribute, please fork this repository. I'd love to have your pull requests sent over.

Right now, the way I'm compiling the tests is by porting over a test suite that I'd written for a Python validator. The tests (in a messy format) can be found here.

There are also other JSON Schema test suites for various other validators, and it would certainly be nice to merge all of them as well. In particular, this validator contains a set of tests already written in JSON which will be useful.

I'm perfectly fine with contributions either porting from one of those, or being written from scratch, so feel free to do what you're comfortable with as long as the tests are easy to understand and correct :).

json-schema-test-suite's People

Contributors

gazpachoking avatar julian avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.