All Projects → Zac-HD → Hypothesis Jsonschema

Zac-HD / Hypothesis Jsonschema

Licence: mpl-2.0
Tools to generate test data from JSON schemata with Hypothesis

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Hypothesis Jsonschema

jsf
Creates fake JSON files from a JSON schema
Stars: ✭ 46 (-58.93%)
Mutual labels:  json-schema, property-based-testing
Beerjson
Development repository for the BeerJSON format standard
Stars: ✭ 109 (-2.68%)
Mutual labels:  json-schema
Schematic
type-safe JSON spec and validation tool
Stars: ✭ 81 (-27.68%)
Mutual labels:  json-schema
Ajv I18n
Internationalised error messages for Ajv JSON-Schema validator
Stars: ✭ 98 (-12.5%)
Mutual labels:  json-schema
Python Lambdarest
Flask like web framework for AWS Lambda
Stars: ✭ 84 (-25%)
Mutual labels:  json-schema
Laravel Json Schema
Create all your migrations and models from one JSON schema file.
Stars: ✭ 101 (-9.82%)
Mutual labels:  json-schema
Docless
A scala DSL to generate JSON schema and swagger documentation for your web services.
Stars: ✭ 78 (-30.36%)
Mutual labels:  json-schema
Jsonschema
JSON Schema validation
Stars: ✭ 1,575 (+1306.25%)
Mutual labels:  json-schema
React Jsonschema Form
A React component for building Web forms from JSON Schema.
Stars: ✭ 10,870 (+9605.36%)
Mutual labels:  json-schema
React Jsonschema Form Material Ui
📜 React - Material UI components for building Web forms from JSON Schema.
Stars: ✭ 95 (-15.18%)
Mutual labels:  json-schema
Swiftcheck
QuickCheck for Swift
Stars: ✭ 1,319 (+1077.68%)
Mutual labels:  property-based-testing
Understanding Json Schema
A website aiming to provide more accessible documentation for JSON schema.
Stars: ✭ 1,268 (+1032.14%)
Mutual labels:  json-schema
Json Node Normalizer
'json-node-normalizer' - NodeJS module that normalize json data types from json schema specifications.
Stars: ✭ 105 (-6.25%)
Mutual labels:  json-schema
Ajv
The fastest JSON schema Validator. Supports JSON Schema draft-04/06/07/2019-09/2020-12 and JSON Type Definition (RFC8927)
Stars: ✭ 10,340 (+9132.14%)
Mutual labels:  json-schema
Schema Registry
Confluent Schema Registry for Kafka
Stars: ✭ 1,647 (+1370.54%)
Mutual labels:  json-schema
Elixir Type check
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects.
Stars: ✭ 80 (-28.57%)
Mutual labels:  property-based-testing
Jesse
jesse (JSon Schema Erlang) is an implementation of a JSON Schema validator for Erlang.
Stars: ✭ 92 (-17.86%)
Mutual labels:  json-schema
Unit Threaded
Advanced unit test framework for D
Stars: ✭ 100 (-10.71%)
Mutual labels:  property-based-testing
Liform
PHP library to render Symfony Forms to JSON Schema
Stars: ✭ 113 (+0.89%)
Mutual labels:  json-schema
Go Jsonschema Generator
json-schemas generator based on Go types
Stars: ✭ 110 (-1.79%)
Mutual labels:  json-schema

hypothesis-jsonschema

A Hypothesis strategy for generating data that matches some JSON schema.

Here's the PyPI page.

API

The public API consists of just one function: hypothesis_jsonschema.from_schema, which takes a JSON schema and returns a strategy for allowed JSON objects.

from hypothesis import given

from hypothesis_jsonschema import from_schema


@given(from_schema({"type": "integer", "minimum": 1, "exclusiveMaximum": 10}))
def test_integers(value):
    assert isinstance(value, int)
    assert 1 <= value < 10


@given(
    from_schema(
        {"type": "string", "format": "card"},
        # Standard formats work out of the box.  Custom formats are ignored
        # by default, but you can pass custom strategies for them - e.g.
        custom_formats={"card": st.sampled_from(EXAMPLE_CARD_NUMBERS)},
    )
)
def test_card_numbers(value):
    assert isinstance(value, str)
    assert re.match(r"^\d{4} \d{4} \d{4} \d{4}$", value)

For more details on property-based testing and how to use or customise strategies, see the Hypothesis docs.

JSONSchema drafts 04, 05, and 07 are fully tested and working. As of version 0.11, this includes resolving non-recursive references!

Supported versions

hypothesis-jsonschema requires Python 3.6 or later. In general, 0.x versions will require very recent versions of all dependencies because I don't want to deal with compatibility workarounds.

hypothesis-jsonschema may make backwards-incompatible changes at any time before version 1.x - that's what semver means! - but I've kept the API surface small enough that this should be avoidable. The main source of breaks will be if or when schema that never really worked turn into explicit errors instead of generating values that don't quite match.

You can sponsor me to get priority support, roadmap input, and prioritized feature development.

Contributing to hypothesis-jsonschema

We love external contributions - and try to make them both easy and fun. You can read more details in our contributing guide, and see everyone who has contributed on GitHub. Thanks, everyone!

Changelog

Patch notes can be found in CHANGELOG.md.

Security contact information

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].