Swagger UI blueprint for Sanic
Project description
Sanic Swagger UI
Simple Sanic blueprint for adding Swagger UI to your sanic application.
Inspired by flask-swagger-ui.
Installation
You can install it using pip.
pip install sanic_swagger_ui
Usage
from sanic import Sanic
from sanic import response
from sanic_swagger_ui import get_swaggerui_blueprint
app = Sanic(__name__)
STATIC_URL = '/static'
app.static(STATIC_URL, './static') # set static dir path
SWAGGER_URL = '/swagger'
DOCS_PATH = STATIC_URL + '/swagger/index.yaml' # serves files from the static dir
swaggerui_blueprint = get_swaggerui_blueprint(
DOCS_PATH,
SWAGGER_URL,
app_name='Swagger BP Test'
)
app.blueprint(swaggerui_blueprint)
@app.route('/')
async def index(req):
return response.html((
'Hello World from Sanic'
'<br>'
'Click <a href="/swagger/docs">here</a> to view swagger docs'),
status=200
)
if __name__ == '__main__':
app.run(debug=True)
You can find this example in examples directory in this repository.
Please add an issue if you want something added here or if you find a bug.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanic-swagger-ui-0.0.2.tar.gz.
File metadata
- Download URL: sanic-swagger-ui-0.0.2.tar.gz
- Upload date:
- Size: 1.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83629557d7fc9c3bc979b1582c4924d18da131b986930387c3ac78ee8cb85275
|
|
| MD5 |
56f2a949c347703158697cc7361b376f
|
|
| BLAKE2b-256 |
461e17c199db0403cb978f9cfde17f5cb6681e723ddf4eade3641802918fdf4e
|
File details
Details for the file sanic_swagger_ui-0.0.2-py3-none-any.whl.
File metadata
- Download URL: sanic_swagger_ui-0.0.2-py3-none-any.whl
- Upload date:
- Size: 1.0 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9fbe8f1161b7b7b0024ecb0f37977c7b85db69f56b937224560a24a556c363ff
|
|
| MD5 |
5d3ff2f47c3f9c9eecbb937b3647491b
|
|
| BLAKE2b-256 |
be9db47946b0f82b41f3b70023e15d3168c7c99aceebd3ed789e3a6ede3f31be
|