Skip to main content
PyPI version CI codecov OpenAPI Specification 2/3 compatible Python compatibility code style: black license: MIT

A library to generate a UI interface from an APISpec specification. As per the APISpec initiative, it currently supports OpenAPI Specification (aka. Swagger specification) and SwaggerUI.

Features

  • Support for the OpenAPI Specification (versions 2 and 3)

  • Compatibility with SwaggerUI (latest version - 4.18.1)

  • Support for frameworks which include:

Installation

Install the package directly from PyPI (recommended):

$ pip install -U apispec-ui

Plugin dependencies like apispec and Flask are not installed with the package by default. To have apispec and Flask installed, run:

$ pip install -U apispec-ui[apispec,flask]

Example usage

A simple example on how to work with a Flask application:

from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from apispec_plugins import FlaskPlugin
from apispec_ui.flask import Swagger
from flask import Flask

app = Flask(__name__)
apispec = APISpec(
    title="Pet Store",
    version="1.0.0",
    openapi_version="3.1.0",
    plugins=(FlaskPlugin(), MarshmallowPlugin()),  # optional
)
...
Swagger(app=app, apispec=apispec, config={})

With this example, the application contains 2 extra views:

  • swagger.ui: endpoint to serve SwaggerUI

  • swagger.specs: endpoint to serve swagger specs, in yaml

With configs parameter one can tweak some parameters:

config = {
    "swaggerui": True,  # enable/disable SwaggerUI
    "swagger_route": "/api/",  # change swagger routes
    "swagger_static": "/static/",  # change location for static files
    "swagger_favicon": "favicon.ico",  # change favicon
    "swagger_hide_bar": True,  # hide SwaggerUI top bar
}

These settings can also be configured through the SWAGGER config variable that is part of the app config.

In terms of precedence, the config that takes the most precedence is the config parameter from Swagger class, followed by the SWAGGER app config.

Tests & linting 🚥

Run tests with tox:

# ensure tox is installed
$ tox

Run linter only:

$ tox -e lint

Optionally, run coverage as well with:

$ tox -e coverage

License

MIT licensed. See LICENSE.

Metadata

Release files for apispec-ui 1.0.0

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

Source distribution (sdist)

Source distribution for apispec-ui 1.0.0
File Size Uploaded
apispec_ui-1.0.0.tar.gz 2.6 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for apispec-ui 1.0.0
File Interpreter ABI Platform
apispec_ui-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 5.2 MB

Release files / apispec_ui-1.0.0.tar.gz

Download URL apispec_ui-1.0.0.tar.gz
Size 2.6 MB
Tags Source
SHA-256 checksum
How to use checksums
460c116ae91dbbdbc29e49143d015283b296063fe9c52f6326ffe294b9f669cd
BLAKE2b-256 checksum
How to use checksums
cb200a8dbfc4778787285396595566bb499f4a6b7caa0ddc1bebc3c1ca8394da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

Release files / apispec_ui-1.0.0-py3-none-any.whl

Download URL apispec_ui-1.0.0-py3-none-any.whl
Size 2.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
6759e4cf7c8e91e0f6279a666a48995a943f5c914f7624332710370549b8b595
BLAKE2b-256 checksum
How to use checksums
6d5dcb43a00b08c6b1e70d0f3aa67e3327af4fccf90dd77b350f5faab01eb449
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.4.0 CPython/3.9.16 Linux/5.15.0-1034-azure

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

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