24

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.

5
  • 2
    Faker combined with json? Commented Feb 5, 2016 at 19:25
  • 1
    Similar to this: npmjs.com/package/dummy-json Commented Feb 5, 2016 at 20:15
  • Right, you could make something similar to that using Faker and the json module. Commented Feb 5, 2016 at 20:17
  • Should not this be a duplicate of stackoverflow.com/questions/12465588/… Commented Feb 5, 2016 at 20:47
  • 2
    I can't believe how this simple question was misinterpreted by so many. Commented Sep 25, 2018 at 15:21

3 Answers 3

7

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
Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

-3

here are the JSON schema generators proposed so far:

bonus:

2 Comments

I 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.