You don’t believe me, look at this.
Once you’ve created the Swagger UI layer, your API documentation is much more presentable to pass onto your line managers, colleagues and third party consumers.
This is a Python Flask Specific implementation. It is expected that you already have at least a minimal Flask REST API with a few end points ready to be documented. If not, you can get the code from here, https://github.com/Sean-Bradley/Seans-Python3-Flask-Rest-Boilerplate
and then run
# pip install -r requirements.txt
Lets get Started
- Open console or bash
# pip install flask_swagger_ui
- Open your
app.pywhere you instantiated Flask and add to the top
from flask_swagger_ui import get_swaggerui_blueprint
- Add a folder to the root of your project and name it
4. Create a new file in it and name it
5. Add some Swagger specific blueprint code after you instantiate Flask
In the above code, a URI is created at the
/swagger endpoint, and it returns a file called
/swagger.json which will be parsed inside a self hosted
Swagger-UI front end.
6. Add the minimum JSON to the
swagger.json file so that we can atleast test it’s working.
7. Start your app
# python app.py
8. And visit
And you should see this below.