An example project for generating a FastAPI Python server from an OpenApi file.
For generating the server from the OpenApi file we will need a generator. Here we use the fastapi-code-generator
pip install fastapi-code-generator
To run the application we will use the Uvicorn package:
pip install unicorn
And for the Server we will need the fastAPI package:
pip install fastapi
To generate the server simply use the following command:
fastapi-codegen --input .\open_api\pet_shop_api.json --output app
After this you will found all the generated files (main.py and models.py) under the app folder.
To run the server just run:
cd app
uvicorn main:app --reload