{"id":13784077,"url":"https://github.com/python-jsonschema/hypothesis-jsonschema","last_synced_at":"2025-05-11T19:32:25.110Z","repository":{"id":33449177,"uuid":"158385624","full_name":"python-jsonschema/hypothesis-jsonschema","owner":"python-jsonschema","description":"Tools to generate test data from JSON schemata with Hypothesis","archived":false,"fork":false,"pushed_at":"2024-03-03T10:21:31.000Z","size":10895,"stargazers_count":236,"open_issues_count":19,"forks_count":27,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-05-23T01:08:08.370Z","etag":null,"topics":["hypothesis","json-schema","property-based-testing","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/hypothesis-jsonschema/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-jsonschema.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Zac-HD","tidelift":"pypi/hypothesis-jsonschema"}},"created_at":"2018-11-20T12:23:34.000Z","updated_at":"2024-06-18T14:03:12.850Z","dependencies_parsed_at":"2024-03-03T10:39:19.345Z","dependency_job_id":null,"html_url":"https://github.com/python-jsonschema/hypothesis-jsonschema","commit_stats":{"total_commits":395,"total_committers":10,"mean_commits":39.5,"dds":"0.24556962025316453","last_synced_commit":"72c50adbce269b404267fc3cdfaa0499e041bb02"},"previous_names":["zac-hd/hypothesis-jsonschema"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-jsonschema%2Fhypothesis-jsonschema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-jsonschema%2Fhypothesis-jsonschema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-jsonschema%2Fhypothesis-jsonschema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-jsonschema%2Fhypothesis-jsonschema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-jsonschema","download_url":"https://codeload.github.com/python-jsonschema/hypothesis-jsonschema/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224713624,"owners_count":17357247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hypothesis","json-schema","property-based-testing","python"],"created_at":"2024-08-03T19:00:35.141Z","updated_at":"2024-11-17T20:31:28.360Z","avatar_url":"https://github.com/python-jsonschema.png","language":"Python","readme":"# hypothesis-jsonschema\n\nA [Hypothesis](https://hypothesis.readthedocs.io) strategy for generating data\nthat matches some [JSON schema](https://json-schema.org/).\n\n[Here's the PyPI page.](https://pypi.org/project/hypothesis-jsonschema/)\n\n## API\n\nThe public API consists of just one function: `hypothesis_jsonschema.from_schema`,\nwhich takes a JSON schema and returns a strategy for allowed JSON objects.\n\n```python\nfrom hypothesis import given\n\nfrom hypothesis_jsonschema import from_schema\n\n\n@given(from_schema({\"type\": \"integer\", \"minimum\": 1, \"exclusiveMaximum\": 10}))\ndef test_integers(value):\n    assert isinstance(value, int)\n    assert 1 \u003c= value \u003c 10\n\n\n@given(\n    from_schema(\n        {\"type\": \"string\", \"format\": \"card\"},\n        # Standard formats work out of the box.  Custom formats are ignored\n        # by default, but you can pass custom strategies for them - e.g.\n        custom_formats={\"card\": st.sampled_from(EXAMPLE_CARD_NUMBERS)},\n    )\n)\ndef test_card_numbers(value):\n    assert isinstance(value, str)\n    assert re.match(r\"^\\d{4} \\d{4} \\d{4} \\d{4}$\", value)\n\n\n@given(from_schema({}, allow_x00=False, codec=\"utf-8\").map(json.dumps))\ndef test_card_numbers(payload):\n    assert isinstance(payload, str)\n    assert \"\\0\" not in payload  # use allow_x00=False to exclude null characters\n    # If you want to restrict generated strings characters which are valid in\n    # a specific character encoding, you can do that with the `codec=` argument.\n    payload.encode(codec=\"utf-8\")\n```\n\nFor more details on property-based testing and how to use or customise\nstrategies, [see the Hypothesis docs](https://hypothesis.readthedocs.io/).\n\nJSONSchema drafts 04, 05, and 07 are fully tested and working.\nAs of version 0.11, this includes resolving non-recursive references!\n\n\n## Supported versions\n\n`hypothesis-jsonschema` requires Python 3.6 or later.\nIn general, 0.x versions will require very recent versions of all dependencies\nbecause I don't want to deal with compatibility workarounds.\n\n`hypothesis-jsonschema` may make backwards-incompatible changes at any time\nbefore version 1.x - that's what semver means! - but I've kept the API surface\nsmall enough that this should be avoidable.  The main source of breaks will be\nif or when schema that never really worked turn into explicit errors instead\nof generating values that don't quite match.\n\nYou can [sponsor me](https://github.com/sponsors/Zac-HD) to get priority\nsupport, roadmap input, and prioritized feature development.\n\n\n## Contributing to `hypothesis-jsonschema`\n\nWe love external contributions - and try to make them both easy and fun.\nYou can [read more details in our contributing guide](https://github.com/Zac-HD/hypothesis-jsonschema/blob/master/CONTRIBUTING.md),\nand [see everyone who has contributed on GitHub](https://github.com/Zac-HD/hypothesis-jsonschema/graphs/contributors).\nThanks, everyone!\n\n\n### Changelog\n\nPatch notes [can be found in `CHANGELOG.md`](https://github.com/Zac-HD/hypothesis-jsonschema/blob/master/CHANGELOG.md).\n\n\n### Security contact information\nTo report a security vulnerability, please use the\n[Tidelift security contact](https://tidelift.com/security).\nTidelift will coordinate the fix and disclosure.\n","funding_links":["https://github.com/sponsors/Zac-HD","https://tidelift.com/funding/github/pypi/hypothesis-jsonschema","https://tidelift.com/security"],"categories":["Who Uses the Test Suite","Python"],"sub_categories":["Python"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-jsonschema%2Fhypothesis-jsonschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-jsonschema%2Fhypothesis-jsonschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-jsonschema%2Fhypothesis-jsonschema/lists"}