I am looking for a python library in which I can feed in my JSON schema and it generates dummy data. I have worked with a similar library in javascript dummy-json. Does anyone about a library which can do the same in python.
Asked
Active
Viewed 1.5k times
21
-
2[Faker](http://fake-factory.readthedocs.org/en/latest/) combined with [`json`](https://docs.python.org/2/library/json.html)? – glibdud Feb 05 '16 at 19:25
-
1Similar to this: https://www.npmjs.com/package/dummy-json – user1733735 Feb 05 '16 at 20:15
-
Right, you could make something similar to that using Faker and the `json` module. – glibdud Feb 05 '16 at 20:17
-
Should not this be a duplicate of http://stackoverflow.com/questions/12465588/convert-a-json-schema-to-a-python-class – dlmeetei Feb 05 '16 at 20:47
-
2I can't believe how this simple question was misinterpreted by so many. – mcsilvio Sep 25 '18 at 15:21
3 Answers
4
A library that does exactly this is hypothesis-jsonschema
Hypothesis is a library that can generate arbitrary data that conforms to a given specification.
hypothesis-jsonschema makes it possible to convert JSON Schema into specifications that can be used by Hypothesis.
Here is an example showing a unit test written using Hypothesis and hypothesis-jsonschema:
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

Alice Heaton
- 1,140
- 11
- 16
1
The most closest what I found within python is https://github.com/ueg1990/faker-schema, but it is not JSON-SCHEMA also there is nodejs implementation that is directly what you are searching for https://github.com/json-schema-faker/json-schema-faker

Sergey Bershadsky
- 611
- 8
- 7
-2
here are the JSON schema generators proposed so far:
- https://github.com/gonvaled/jskemator (1 input but allows iteration)
- https://github.com/perenecabuto/json_schema_generator (1 input)
- https://github.com/rnd0101/json_schema_inferencer (1 input I think)
- https://github.com/wolverdude/GenSON/ (multiple inputs)
- https://pypi.python.org/pypi/skinfer (multiple inputs)
bonus:
- http://www.jsonschema.net (1 input)

Döme
- 835
- 11
- 23
-
3I dont want to generate schema. I have a schema or maybe one sample JSON. I want to generate random data from that. It should be random every time – user1733735 Feb 05 '16 at 19:47
-
1@user1733735 online: + http://schematic-ipsum.herokuapp.com/ + http://experiments.mennovanslooten.nl/2010/mockjson/tryit.html + http://www.json-generator.com/ + http://json-generator.appspot.com/ python, perhabs this is help to you: + https://github.com/hamstah/apitools + http://www.joke2k.net/faker/ – Döme Feb 05 '16 at 21:01