root/alpine313/: jsf-0.11.2 metadata and description

Homepage Simple index PyPI page

Creates fake JSON files from a JSON schema

author ghandic
classifiers
  • Programming Language :: Python :: 3
  • License :: OSI Approved :: MIT License
  • Operating System :: OS Independent
description_content_type text/markdown
keywords JSON Schema, Fake data, Test data, Schema, JSON, Faker, Hypothesis, Rapid Prototype, Data contract
requires_dist
  • faker (>=15.3.4)
  • jsonschema (>=4.17.3)
  • pydantic (>=2.0.0)
  • rstr (>=3.2.0)
  • smart-open[http] (>=6.3.0)
  • typing-extensions (>=4.9.0)
  • typer (>=0.7.0) ; extra == 'cli'
requires_python >=3.8
File Tox results History
jsf-0.11.2-py3-none-any.whl
Size
48 KB
Type
Python Wheel
Python
3

jsf

Coverage Docs PyPI Latest Release
License Code style: black

Use jsf along with fake data generators to provide consistent and meaningful fake data for your system.

Main Features

Installation

$ pip install jsf

---> 100%

Usage

Basic 😊

from jsf import JSF

faker = JSF(
    {
        "type": "object",
        "properties": {
            "name": {"type": "string", "$provider": "faker.name"},
            "email": {"type": "string", "$provider": "faker.email"},
        },
        "required": ["name", "email"],
    }
)

fake_json = faker.generate()

Results in ...

{
    'name': 'Jesse Phillips', 
    'email': 'xroberson@hotmail.com'
}

From JSON file 📁

from jsf import JSF

faker = JSF.from_json("demo-schema.json")
fake_json = faker.generate()
Or run straight from the commandline...

Native install

pip install jsf[cli]
jsf --schema jsf/tests/data/custom.json --instance wow.json

Docker

docker run -v $PWD:/data challisa/jsf jsf --schema /data/custom.json --instance /data/example.json

FastAPI Integration 🚀

Create a file main.py with:

from jsf import JSF
from fastapi import FastAPI

app = FastAPI(docs_url="/")
generator = JSF.from_json("custom.json")


@app.get("/generate", response_model=generator.pydantic())
def read_root():
    return generator.generate()

Run the server with:

$ uvicorn main:app --reload

INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [28720]
INFO:     Started server process [28722]
INFO:     Waiting for application startup.
INFO:     Application startup complete.

Navigate to http://127.0.0.1:8000 and check out your endpoint. Notice the following are all automatically created:

  • Schema with descriptions and examples
  • Example response
  • Data generation by clicking "try it out"

Example Swagger UI - Page 1 Example Swagger UI - Page 2 Example Swagger UI - Page 3 Example Swagger UI - Page 4

Partially supported features

Credits

License