{"id":4045,"library":"hypothesis-jsonschema","title":"Hypothesis JSONSchema","description":"Hypothesis-jsonschema is a Python library that provides a Hypothesis strategy for generating test data that conforms to a given JSON schema. It is currently in version 0.23.1. As a 0.x release series, it may introduce backwards-incompatible changes before reaching 1.0. It supports JSONSchema drafts 04, 05, and 07, including resolving non-recursive references.","status":"active","version":"0.23.1","language":"en","source_language":"en","source_url":"https://github.com/Zac-HD/hypothesis-jsonschema","tags":["testing","property-based-testing","json-schema","hypothesis","fuzzing","data-generation"],"install":[{"cmd":"pip install hypothesis-jsonschema","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core property-based testing framework that hypothesis-jsonschema extends.","package":"hypothesis"},{"reason":"Required for parsing and understanding JSON schemas (version 0.7.0 required >= 3.0).","package":"jsonschema","optional":false}],"imports":[{"symbol":"from_schema","correct":"from hypothesis_jsonschema import from_schema"}],"quickstart":{"code":"from hypothesis import given, settings, HealthCheck\nfrom hypothesis_jsonschema import from_schema\n\n# Basic example: generate integers within a range\n@given(from_schema({\"type\": \"integer\", \"minimum\": 1, \"exclusiveMaximum\": 10}))\ndef test_integers(value):\n    assert isinstance(value, int)\n    assert 1 <= value < 10\n\n# Example with string formats and avoiding null characters\n# (Note: custom_formats argument can be used for non-standard formats)\n@given(from_schema({'type': 'string', 'format': 'uuid'}))\ndef test_uuid_string(value):\n    import re\n    assert isinstance(value, str)\n    assert re.match(r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$', value)\n\n# To demonstrate, typically you'd run these with pytest or similar test runner\n# For standalone execution, you'd call the functions, but Hypothesis normally runs tests implicitly\n\n# Example of using settings to suppress health checks if needed (not recommended for general use)\n@given(from_schema({\"type\": \"number\"}))\n@settings(suppress_health_check=[HealthCheck.filter_too_much])\ndef test_numbers(value):\n    assert isinstance(value, (int, float))\n\nprint(\"Quickstart examples defined. Run with pytest to execute.\")","lang":"python","description":"Demonstrates the core usage of `from_schema` to generate data matching simple JSON schemas. It includes examples for integers, strings with formats, and a note on common `hypothesis.settings` usage."},"warnings":[{"fix":"Always pin to exact minor versions (e.g., `hypothesis-jsonschema==0.23.*`) and review changelogs carefully when upgrading between minor versions.","message":"As a 0.x series library, `hypothesis-jsonschema` adheres to semantic versioning but may introduce backwards-incompatible changes at any point before version 1.0. The primary source of such breaks often involves schemas that previously behaved ambiguously or produced incorrect values now raising explicit errors.","severity":"breaking","affected_versions":"0.x series (current: 0.23.1)"},{"fix":"For schemas with recursive references, you might need to manually craft strategies for the recursive parts or consider alternative generation methods. Keep an eye on the project's issue tracker for updates on recursive `$ref` support.","message":"The library has a known limitation in its support for *recursive* references within JSON schemas (e.g., using `$ref` for self-referential schemas), which are commonly found in complex specifications like OpenAPI. While non-recursive references are supported since v0.11, full recursive support is an ongoing challenge.","severity":"gotcha","affected_versions":"<1.0"},{"fix":"Ensure your environment has the latest compatible versions of `hypothesis` and `jsonschema`. If encountering issues, try upgrading these dependencies first.","message":"The 0.x versions of `hypothesis-jsonschema` generally require very recent versions of all its dependencies. This is a design choice by the maintainer to avoid complex compatibility workarounds, which means older dependency versions might not work as expected.","severity":"gotcha","affected_versions":"0.x series (current: 0.23.1)"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}