Swagger UI for Python web framework, such Tornado, Flask, Quart and Sanic.
Project description
swagger-ui-py
Swagger UI for Python web framework, such Tornado, Flask, Quart, aiohttp and Sanic.
Only support Python3.
Usage
-
Install
pip3 install swagger-ui-py
-
Code
Using the local config file
from swagger_ui import api_doc api_doc(app, config_path='./config/test.yaml', url_prefix='/api/doc', title='API doc')
Using config url, but need to suport CORS
api_doc(app, config_url='https://petstore.swagger.io/v2/swagger.json', url_prefix='/api/doc', title='API doc')
And suport config file editor
api_doc(app, config_path='./config/test.yaml', editor=True)
And keep the old way
# for Tornado from swagger_ui import tornado_api_doc tornado_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc') # for Sanic from swagger_ui import sanic_api_doc sanic_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc') # for Flask from swagger_ui import flask_api_doc flask_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc') # for Quart from swagger_ui import quart_api_doc quart_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc') # for aiohttp from swagger_ui import aiohttp_api_doc aiohttp_api_doc(app, config_path='./conf/test.yaml', url_prefix='/api/doc', title='API doc')
-
Edit
Swagger
config file (JSON or YAML)Please see https://swagger.io/resources/open-api/.
-
Access
Open
http://<host>:<port>/api/doc/editor
, you can edit api doc config file.Open
http://<host>:<port>/api/doc
view api doc.
Swagger UI
Swagger UI version is 3.22.0
. see https://github.com/swagger-api/swagger-ui.
Swagger Editor
Swagger Editor version is 3.6.27
. see https://github.com/swagger-api/swagger-editor.
Update
You can update swagger ui and swagger editor version with
cd swagger-ui-py/tools
python update.py ui
# or
python update.py editor
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for swagger-ui-py-0.1.9.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e6cd90a09c15e27a96699b0fef9f57cba3540ac9fc57472d646e501a2a42c3a |
|
MD5 | 7ea309fe3061c9c0413bd5974ca1be22 |
|
BLAKE2b-256 | b2c54d24927763b7cd82548450125e9044e052af1a04c880c96368011e38fa73 |
Hashes for swagger_ui_py-0.1.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64b535aa7bc3124dbea9c3711bb872f7fd17daf1ab27273d33a3942265fbcd89 |
|
MD5 | fb395918881a5d778ffdae8c483003e6 |
|
BLAKE2b-256 | 5c02f30c2f90ec2ae99cd59163da401b5ad818bfc4a738cd9223eeebd9c6aba4 |