Skip to main content

aws-flask-swagger-ui

Tests Status Release Status

Simple Flask blueprint for adding Swagger UI to your flask application. Including a WSGI adapter for AWS API Gateway/Lambda Proxy Integration to allows you to use WSGI-compatible middleware and frameworks like Flask and Django with the AWS API Gateway/Lambda proxy integration for your Swagger documentation.

Included Swagger UI version: see here

Installation

pip install aws-flask-swagger-ui

Usage

Simple usage example is shown below for more options check the file extend examples:

from flask import Flask
from aws_flask_swagger_ui import get_swaggerui_blueprint, flask_ui_response

app = Flask(__name__)

swaggerui_blueprint = get_swaggerui_blueprint(
    "/api-doc",
    aws_gw_config={
        "exportType": "oas30",
        "parameters": {
            "extensions": "integrations",
            "extensions": "apigateway",
            "extensions": "authorizers",
        },
    },
)

app.register_blueprint(swaggerui_blueprint)


def lambda_handler(event, context):
    return flask_ui_response(app, event, context, base64_content_types={"image/png"})

AWS Gateway Configuration

http://mysite.com = https://restApiId.execute-api.region.amazonaws.com/stage/

In order that the above example works correctly the Lambda function must be connected as Proxy to the endpoint http://mysite.com/api-doc/

Configure your API Gateway with a {proxy+} resource with an ANY method. Your "Method Response" should likely include an application/json "Response Body for 200" that uses the Empty model.

Because API Gateway doesn't match the root folder with {proxy+} definition, your default URL should contain index.html. It is suggested to create a mock integration on your path /api-doc to return a 301. (ex: /api-doc => 301 => /api-doc/index.html) Source code based on Terraform to achieve this can be found in this article.

Lambda Test Event

The Lambda function must have the permissions to export the API definition!

If you wish to use the "Test" functionality in Lambda for your function, you will need a "API Gateway AWS Proxy" event. Check the event JSON objects in the events folder.

To update your test event, click "Actions" -> "Configure test event".

Within the Events you need to update the "apiId" and "stage" with values for your AWS account.

Protect documentation with password

If you create an environment variable like, SWAGGER_PASSWORD=abc

Then you will need to pass a query parameter in the URL like, http://mysite.com/api-doc/?pass=abc

If you don't have the environment variable then endpoint is not password protected and you can access it as per normal http://mysite.com/api-doc/

Protect documentation with HTTP Basic Auth

For a real username/password prompt (handled by the browser, and covering the Swagger UI page as well as its static assets), pass basic_auth_credentials or set the SWAGGER_BASIC_AUTH_USER / SWAGGER_BASIC_AUTH_PASSWORD environment variables:

swaggerui_blueprint = get_swaggerui_blueprint(
    "/api-doc",
    aws_gw_config={"exportType": "oas30"},
    basic_auth_credentials=("myuser", "mypassword"),
)

or, without code changes:

export SWAGGER_BASIC_AUTH_USER=myuser
export SWAGGER_BASIC_AUTH_PASSWORD=mypassword

Explicit basic_auth_credentials takes precedence over the environment variables. If neither is set the endpoint is not protected. This is independent of the SWAGGER_PASSWORD query-parameter protection above and both can be combined.

Configuration

The blueprint supports overloading all Swagger UI configuration options that can be JSON serialized. See swagger-ui configuration for options.

Plugins and function parameters are not supported at this time.

OAuth2 parameters can be found at swagger-ui oauth2.

License

This library is licensed under the Apache 2.0 License.

Test

  • Clone the repo and run pytest
git clone https://github.com/tb102122/aws_flask_swagger_ui.git
python -m venv virtualenv
virtualenv/bin/activate
pip install --upgrade pip, setuptools, wheel
pip install flake8 pytest boto3 pytest-cov
pip install .
flake8 .
pytest

Metadata

Release files for aws-flask-swagger-ui 1.2.3

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

Source distribution (sdist)

Source distribution for aws-flask-swagger-ui 1.2.3
File Size Uploaded Provenance Actions
aws_flask_swagger_ui-1.2.3.tar.gz 3.2 MB With provenance Details for aws_flask_swagger_ui-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aws-flask-swagger-ui 1.2.3
File Interpreter ABI Platform Actions
aws_flask_swagger_ui-1.2.3-py3-none-any.whl Python 3 none any Details for aws_flask_swagger_ui-1.2.3-py3-none-any.whl

Total release size: 6.4 MB

Release files / aws_flask_swagger_ui-1.2.3.tar.gz

Download URL aws_flask_swagger_ui-1.2.3.tar.gz
Size 3.2 MB
Tags Source
SHA-256 checksum
How to use checksums
92845f6c4302cb105686590eb32f4d1def7a7e7899826267af6511b20e624b18
BLAKE2b-256 checksum
How to use checksums
0e6028970e37d679534ed58ebc15c380b389db672735b8465f0b65792f077321
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / aws_flask_swagger_ui-1.2.3-py3-none-any.whl

Download URL aws_flask_swagger_ui-1.2.3-py3-none-any.whl
Size 3.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
cc6d1b69a1cba6354ad0cc386598d6e74cb739198dc68a0a21f806f24b6703ef
BLAKE2b-256 checksum
How to use checksums
cad8408870fa96e13819bca3c10eb80f77f3cd829a9c2e0ff9a1ae1601014b94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for aws-flask-swagger-ui 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aws_flask_swagger_ui-1.2.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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