swagger_ui_bundle - swagger-ui files in a pip package
Project description
swagger_ui_bundle
This package contains the static files for swagger-ui as a python package.
Basic configuration options are templated with the Jinja2 templating language.
This package is intended to be webserver-agnostic, so it only includes the static files, and some very basic configuration.
Getting Started
You can import the swagger_ui_path from the swagger_ui_bundle package like so:
from swagger_ui_bundle import swagger_ui_path
# or if you need a specific version
from swagger_ui_bundle import swagger_ui_2_path
from swagger_ui_bundle import swagger_ui_3_path
You can easily serve up this directory as all static files to get the default swagger-ui distribution. Here’s an example in flask:
from swagger_ui_bundle import swagger_ui_path
from flask import Flask, Blueprint, send_from_directory, render_template
swagger_bp = Blueprint(
'swagger_ui',
__name__,
static_url_path='',
static_folder=swagger_ui_path,
template_folder=swagger_ui_path
)
app = Flask(__name__, static_url_path='')
app.register_blueprint(swagger_bp, url_prefix='/ui')
if __name__ == "__main__":
app.run()
You may wish to override some of the configuration variables. Included is a jinaj2 templated file where you can modify these parameters. You can add another route to render this template with your desired configuration like so:
SWAGGER_UI_CONFIG = {
"openapi_spec_url": "https://petstore.swagger.io/v2/swagger.json"
}
@swagger_bp.route('/')
def swagger_ui_index():
return render_template('index.j2', **SWAGGER_UI_CONFIG)
Have a look at example.py for a complete server for the Flask webserver.
License
Since this is just repackaging swagger-ui releases, the license comes from the swagger ui project (https://github.com/swagger-api/swagger-ui).
All vendored code is published by SmartBear Software under the Apache 2.0 License.
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 Distributions
Hashes for swagger_ui_bundle-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f776811855092c086dbb08216c8810a84accef8c76c796a135caa13645c5cc68 |
|
MD5 | c2e2d463571c241971fd9901f2e8b7be |
|
BLAKE2b-256 | 693349fdd2ae1680bbc6d9d50fbce91bb9a147519fdafdf10231821dc9171ff4 |
Hashes for swagger_ui_bundle-0.0.6-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d2e12d60a6499e9d37ea37953b5d700f4e114edc7520fe918bae5eb693a20e |
|
MD5 | 0a3791b3e0bc75ed381bc1d21dd780af |
|
BLAKE2b-256 | eb4eb93d11f78980054b5ee6e1a82ff747dacb64738dee90607a57c015fe3d05 |