- Copy files from this repo Structure of your project now should be:
.
├── static
| ├── hello_api.json
│ ├── css
│ │ └── swagger-ui.css
│ ├── img
│ │ ├── favicon-16x16.png
│ │ └── favicon-32x32.png
│ └── js
│ ├── swagger-ui-bundle.js
│ ├── swagger-ui-standalone-preset.js
│ └── swagger-ui.js
└── templates
├── swaggerui.html
-
Write your API spec for Swagger. Go to Swagger Editor and write your API spec in YAML.
-
Once you are ready go to File->Convert and save as JSON. Example of such json. Also Swagger Editor itself by default gives you a great example
-
Put your generated json in
static/hello_api.json
-
Return swaggerui.html with flask render_template in your preferred route, example:
@app.route('/api/docs')
def get_docs():
print('sending docs')
return render_template('swaggerui.html')
Example of JSON for bank-bot
If you change your json config file but don't see any change in Swagger then hold down the Shift button and click the Reload button (because browsers cache some files, this will force it to update config file)