Your Python Flask API is Nothing Without Swagger UI.

Sean Bradley
4 min readApr 17, 2019

You don’t believe me, look at this.

Much better.

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,
and then run # pip install -r requirements.txt

Lets get Started

  1. Open console or bash
    # pip install flask_swagger_ui
  2. Open your where you instantiated Flask and add to the top
    from flask_swagger_ui import get_swaggerui_blueprint
  3. Add a folder to the root of your project and name it static.

4. Create a new file in it and name it swagger.json

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

8. And visit

And you should see this below.

Sean Bradley

Developer of real time, low latency, high availability, asynchronous, multi threaded, remotely managed, fully automated and monitored solutions.