1- # jsf
2-
3- <img src =" docs/assets/imgs/index.png " width =" 100 " >
4-
5- [ ![ coverage] ( https://img.shields.io/codecov/c/github/ghandic/jsf?color=%2334D058 )] ( https://codecov.io/gh/ghandic/jsf )
6- [ ![ documentation] ( https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat )] ( https://ghandic.github.io/jsf/index.html )
7- [ ![ PyPI Latest Release] ( https://img.shields.io/pypi/v/jsf.svg )] ( https://pypi.org/project/jsf/ )
8- [ ![ License] ( https://img.shields.io/github/license/ghandic/jsf.svg )] ( https://github.com/ghandic/jsf/blob/main/LICENSE )
9- [ ![ Code style: black] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/psf/black )
10-
11- ## What is it
12-
13- This repository is a Python port of [ json-schema-faker] ( https://github.com/json-schema-faker/json-schema-faker ) with some minor differences in implementation.
14-
15- > Use ** jsf** along with fake generators to provide consistent and meaningful fake data for your system.
1+ <h1 align =" center " >
2+ <strong >jsf</strong ><img src =" docs/assets/imgs/index.png " width =" 50 " style =" position : absolute ; padding-left :10px ;" >
3+ </h1 >
4+
5+ <p align =" center " >
6+ <a href="https://codecov.io/gh/ghandic/jsf" target="_blank">
7+ <img src="https://img.shields.io/codecov/c/github/ghandic/jsf?color=%2334D058" alt="Coverage">
8+ </a>
9+ <a href="https://ghandic.github.io/jsf/index.html" target="_blank">
10+ <img src="https://img.shields.io/badge/docs-mkdocs%20material-blue.svg?style=flat" alt="Docs">
11+ </a>
12+ <a href="https://pypi.org/project/jsf/" target="_blank">
13+ <img src="https://img.shields.io/pypi/v/jsf.svg" alt="PyPI Latest Release">
14+ </a>
15+ <br />
16+ <a href="https://github.com/ghandic/jsf/blob/main/LICENSE" target="_blank">
17+ <img src="https://img.shields.io/github/license/ghandic/jsf.svg" alt="License">
18+ </a>
19+ <a href="https://github.com/psf/black" target="_blank">
20+ <img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black">
21+ </a>
22+ </p >
23+
24+
25+ Use ** jsf** along with fake data generators to provide consistent and meaningful fake data for your system.
1626
1727## Main Features
1828
19- * Provides out of the box data generation from any JSON schema
20- * Extendable custom data providers using any lambda functions
21- * Multi level state for dependant data (eg multiple objects sharing value, such as children with same surname)
22- * Inbuilt validation of fake JSON produced
29+ - Provides out of the box data generation from any JSON schema 📦
30+ * Extendable custom data providers using any lambda functions 🔗
31+ * Multi level state for dependant data (eg multiple objects sharing value, such as children with same surname) 🤓
32+ * Inbuilt validation of fake JSON produced ✅
33+ * In memory conversion from JSON Schema to Pydantic Models with generated examples 🤯
34+ * Seamless integration with [ FastAPI] ( https://fastapi.tiangolo.com/ ) 🚀
2335
24- ## Where to get it
36+ ## Installation
2537
26- The source code is currently hosted on GitHub at: https://github.com/ghandic/jsf
38+ < div class = " termy " >
2739
28- Binary installers for the latest released version are available at the [ Python package index] ( https://pypi.org/project/jsf/ )
40+ ``` console
41+ $ pip install jsf
2942
30- ``` bash
31- pip install jsf
43+ ---> 100%
3244```
3345
34- ## Dependencies
46+ </ div >
3547
36- * faker - For fake data provisioning
37- * rstr - For building strings from regex patterns
38- * smart_open - For opening external $ref
39- * jsonschema - For schema/instance validation
40- * typer - For neat commandline applications
41- * pydantic - For easy serialization and validation
48+ ## Usage
4249
43- ## License
50+ ### Basic 😊
4451
45- * [ MIT License] ( /LICENSE )
52+ ``` python
53+ from jsf import JSF
4654
47- ## Usage
55+ faker = JSF(
56+ {
57+ " type" : " object" ,
58+ " properties" : {
59+ " name" : {" type" : " string" , " $provider" : " faker.name" },
60+ " email" : {" type" : " string" , " $provider" : " faker.email" },
61+ },
62+ " required" : [" name" , " email" ],
63+ }
64+ )
4865
49- ### As a program
66+ fake_json = faker.generate()
67+ ```
5068
51- * pip install jsf
52- * In your code where you need to you will be using jsf you can refer to below script as reference:
69+ Results in ...
70+
71+ ``` json
72+ {
73+ name': 'Jesse Phillips',
74+ 75+ }
76+ ```
77+
78+ ### From JSON file 📁
5379
5480``` python
5581from jsf import JSF
@@ -58,9 +84,10 @@ faker = JSF.from_json("demo-schema.json")
5884fake_json = faker.generate()
5985```
6086
61- ### From the commandline
87+ <details markdown =" 1 " >
88+ <summary >Or run stright from the <code >commandline</code >...</summary >
6289
63- #### Raw install
90+ #### Native install
6491
6592``` bash
6693jsf --schema src/tests/data/custom.json --instance wow.json
@@ -69,24 +96,61 @@ jsf --schema src/tests/data/custom.json --instance wow.json
6996#### Docker
7097
7198``` bash
72- docker build . -t challisa/jsf
73- docker run -v $PWD :/data challisa/jsf jsf --schema /data/src/tests/data/custom.json --instance /data/wow.json
99+ docker run -v $PWD :/data challisa/jsf jsf --schema /data/custom.json --instance /data/example.json
74100```
75101
76- ## Mkdocs
102+ </ details >
77103
78- The documentation for this project is written in Markdown and built using mkdocs, the easiest way to get the docs up for development is to run it in Docker
79104
80- ``` bash
81- docker-compose up mkdocs-jsf
105+ ### FastAPI Integration 🚀
106+
107+ Create a file main.py with:
108+
109+ ``` python
110+ from jsf import JSF
111+ from fastapi import FastAPI
112+
113+ app = FastAPI(docs_url = " /" )
114+ generator = JSF .from_json(" custom.json" )
115+
116+
117+ @app.get (" /generate" , response_model = generator.pydantic())
118+ def read_root ():
119+ return generator.generate()
120+
82121```
83122
84- ## Contributing to jsf
123+ Run the server with:
124+
125+ <div class =" termy " >
85126
86- To contribute to jsf, follow these steps:
127+ ``` console
128+ $ uvicorn main:app --reload
129+
130+ INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
131+ INFO: Started reloader process [28720]
132+ INFO: Started server process [28722]
133+ INFO: Waiting for application startup.
134+ INFO: Application startup complete.
135+ ```
87136
88- 1 . Fork the repository
89- 2 . Create a branch in your own fork: ` git checkout -b <branch_name> ` .
90- 3 . Make your changes and commit them: ` git commit -m '<commit_message>' `
91- 4 . Push to the original branch: ` git push origin <project_name>/<location> `
92- 5 . Create the pull request back to our fork.
137+ Navigate to [ http://127.0.0.1:8000 ] ( http://127.0.0.1:8000 ) and check out your endpoint. Notice the following are all automatically created:
138+
139+ - Schema with descriptions and examples
140+ - Example response
141+ - Data generation by clicking "try it out"
142+
143+ ![ Example Swagger UI - Page 1] ( docs/assets/imgs/ui-1.png )
144+ ![ Example Swagger UI - Page 2] ( docs/assets/imgs/ui-2.png )
145+ ![ Example Swagger UI - Page 3] ( docs/assets/imgs/ui-3.png )
146+ ![ Example Swagger UI - Page 4] ( docs/assets/imgs/ui-4.png )
147+
148+ </div >
149+
150+ ## Credits
151+
152+ - This repository is a Python port of [ json-schema-faker] ( https://github.com/json-schema-faker/json-schema-faker ) with some minor differences in implementation.
153+
154+ ## License
155+
156+ * [ MIT License] ( /LICENSE )
0 commit comments