All Projects → ghandic → jsf

ghandic / jsf

Licence: MIT License
Creates fake JSON files from a JSON schema

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to jsf

Hypothesis Jsonschema
Tools to generate test data from JSON schemata with Hypothesis
Stars: ✭ 112 (+143.48%)
Mutual labels:  json-schema, property-based-testing
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+85960.87%)
Mutual labels:  json-schema, fastapi
Full Stack Fastapi Postgresql
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Stars: ✭ 7,635 (+16497.83%)
Mutual labels:  json-schema, fastapi
restish
Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in
Stars: ✭ 453 (+884.78%)
Mutual labels:  json-schema, fastapi
xml-lint
A php tool to lint and validate xml files from the commandline.
Stars: ✭ 14 (-69.57%)
Mutual labels:  commandline
edd
Erlang Declarative Debugger
Stars: ✭ 20 (-56.52%)
Mutual labels:  property-based-testing
py-spotme
A CLI tool that creates AWS spot instances on the fly
Stars: ✭ 16 (-65.22%)
Mutual labels:  commandline
json2object
Type safe Haxe/JSON (de)serializer
Stars: ✭ 54 (+17.39%)
Mutual labels:  json-schema
form-pa
A flexible and configurable form based on json schema
Stars: ✭ 13 (-71.74%)
Mutual labels:  json-schema
fastapi-boilerplate
FastAPI boilerplate for real world production
Stars: ✭ 145 (+215.22%)
Mutual labels:  fastapi
rsfetch
A WIP rewrite of rsfetch from scratch.
Stars: ✭ 33 (-28.26%)
Mutual labels:  commandline
mongoose-schema-jsonschema
Mongoose extension that allows to build json schema for mongoose models, schemes and queries
Stars: ✭ 88 (+91.3%)
Mutual labels:  json-schema
recommendation-api
Rank and serve recommendations
Stars: ✭ 14 (-69.57%)
Mutual labels:  fastapi
metrics
IS, FID score Pytorch and TF implementation, TF implementation is a wrapper of the official ones.
Stars: ✭ 91 (+97.83%)
Mutual labels:  commandline
minifaker
A lightweight alternative to faker.js
Stars: ✭ 64 (+39.13%)
Mutual labels:  faker
opis-error-presenter
JSON-schema error presenter for opis/json-schema library
Stars: ✭ 17 (-63.04%)
Mutual labels:  json-schema
JSON-NLP
JSON-NLP Schema for transfer of NLP output using JSON
Stars: ✭ 38 (-17.39%)
Mutual labels:  json-schema
exch
a command-line tool to see currency exchange rates
Stars: ✭ 20 (-56.52%)
Mutual labels:  commandline
datafaker
Brings the popular ruby faker gem to Java and Kotlin
Stars: ✭ 138 (+200%)
Mutual labels:  faker
schema-shot
Framework-agnostic snapshot testing using "schema by example" for highly dynamic data
Stars: ✭ 34 (-26.09%)
Mutual labels:  json-schema

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

  • Provides out of the box data generation from any JSON schema 📦
  • Extendable custom data providers using any lambda functions 🔗
  • Multi level state for dependant data (eg multiple objects sharing value, such as children with same surname) 🤓
  • Inbuilt validation of fake JSON produced
  • In memory conversion from JSON Schema to Pydantic Models with generated examples 🤯
  • Seamless integration with FastAPI 🚀

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': '[email protected]'
}

From JSON file 📁

from jsf import JSF

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

Native install

jsf --schema src/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

Credits

  • This repository is a Python port of json-schema-faker with some minor differences in implementation.

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].