Skip to main content

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.

Metadata

Release files for sanic-swagger-ui 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sanic-swagger-ui 0.0.2
File Size Uploaded
sanic-swagger-ui-0.0.2.tar.gz 1.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for sanic-swagger-ui 0.0.2
File Interpreter ABI Platform
sanic_swagger_ui-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / sanic-swagger-ui-0.0.2.tar.gz

Download URL sanic-swagger-ui-0.0.2.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
83629557d7fc9c3bc979b1582c4924d18da131b986930387c3ac78ee8cb85275
BLAKE2b-256 checksum
How to use checksums
461e17c199db0403cb978f9cfde17f5cb6681e723ddf4eade3641802918fdf4e
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / sanic_swagger_ui-0.0.2-py3-none-any.whl

Download URL sanic_swagger_ui-0.0.2-py3-none-any.whl
Size 1.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9fbe8f1161b7b7b0024ecb0f37977c7b85db69f56b937224560a24a556c363ff
BLAKE2b-256 checksum
How to use checksums
be9db47946b0f82b41f3b70023e15d3168c7c99aceebd3ed789e3a6ede3f31be
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page