Skip to content

Commit e167831

Browse files
committed
Add usage example to README
Closes #56.
1 parent e041bfc commit e167831

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ that matches some [JSON schema](https://json-schema.org/).
1010
The public API consists of just one function: `hypothesis_jsonschema.from_schema`,
1111
which takes a JSON schema and returns a strategy for allowed JSON objects.
1212

13+
```python
14+
from hypothesis import given
15+
from hypothesis_jsonschema import from_schema
16+
17+
@given(from_schema(
18+
{"type": "integer", "minimum": 1, "exclusiveMaximum": 10}
19+
))
20+
def test(value):
21+
assert isinstance(value, int)
22+
assert 1 <= value < 10
23+
```
24+
25+
For more details on property-based testing and how to use or customise
26+
strategies, [see the Hypothesis docs](https://hypothesis.readthedocs.io/).
27+
1328
JSONSchema drafts 04, 05, and 07 are fully tested and working.
1429
As of version 0.11, this includes resolving non-recursive references!
1530

16-
For details on how to use this strategy in your tests,
17-
[see the Hypothesis docs](https://hypothesis.readthedocs.io/).
18-
1931

2032
## Supported versions
2133

0 commit comments

Comments
 (0)