Registry / web-framework / flask-swagger-ui

flask-swagger-ui

JSON →
library5.32.6pypypi✓ verified 86d ago

Flask-Swagger-UI is a Python library that provides a simple Flask blueprint to integrate Swagger UI into your Flask applications. It currently bundles Swagger UI version 5.32.1. While the project is not actively maintained, it receives occasional updates to keep the bundled Swagger UI version current. Users requiring more active development or specific new features might consider forking the repository.

pip install flask-swagger-ui
INSTALL
IMPORT
SIG · FLASK-SWAGGER-UI
F
flask-swagger-ui
web-frameworkpythonv5.32.6
Install
2.2s avg
Import
479ms
Disk
23MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v5.32.6 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.497s · 24.7MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.2s · import 0.461s · 25MB
23MB installed
● package 23MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

get_swaggerui_blueprint
from flask_swagger_ui import get_swaggerui_blueprint

This example sets up a basic Flask application and registers the Swagger UI blueprint, pointing to a remote OpenAPI specification. After running, navigate to `/api/docs` in your browser to see the Swagger UI.

from flask import Flask from flask_swagger_ui import get_swaggerui_blueprint app = Flask(__name__) SWAGGER_URL = '/api/docs' # URL for exposing Swagger UI (without trailing '/') API_URL = 'https://petstore.swagger.io/v2/swagger.json' # Our API url (can of course be a local resource) # Call factory function to create our blueprint swaggerui_blueprint = get_swaggerui_blueprint( SWAGGER_URL, # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/' API_URL, config={ 'app_name': 'Test application' } ) app.register_blueprint(swaggerui_blueprint) @app.route('/') def hello_world(): return 'Hello, World!' if __name__ == '__main__': app.run(debug=True)
Debug
Known issues
gotchaThe `flask-swagger-ui` project is not actively maintained, though it receives occasional updates primarily for bundling the latest Swagger UI. Users requiring more active feature development or prompt bug fixes may need to consider forking the repository.
fix
Review the project's GitHub for recent activity. For custom features or critical bug fixes, consider forking the repository or integrating Swagger UI manually.
affects: All versions
gotchaWhen using a local `swagger.json` or `openapi.json` file as the `API_URL`, ensure that Flask is configured to serve static files from the directory where your API definition resides. Common issues include 'Fetch error: Not Found' if the static path is incorrect or the file isn't accessible via the web server.
fix
For local files, ensure `API_URL` correctly points to a Flask static route (e.g., `/static/swagger.json`) and that the file exists in the corresponding static folder.
affects: All versions
gotchaThe `get_swaggerui_blueprint` factory function supports overriding Swagger UI configuration options that can be JSON serialized via the `config` dictionary parameter. However, it does *not* support Swagger UI plugins or function parameters for advanced customization.
fix
For advanced Swagger UI features like plugins or custom functions, you may need to integrate Swagger UI directly into your Flask application without using this blueprint, or investigate alternative Flask extensions that offer more control.
affects: All versions
gotcha`flask-swagger-ui` provides a standalone blueprint for Swagger UI. It is different from the built-in Swagger UI functionality offered by `Flask-RESTPlus` (now `Flask-RESTX`), which integrates Swagger documentation directly with API definitions.
fix
If you are using Flask-RESTX for API development, its integrated documentation might be a more seamless solution. Otherwise, ensure your API definition is separate and served correctly for `flask-swagger-ui`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'flask_swagger_ui'
The 'flask-swagger-ui' Python package has not been installed in your current environment, or the import statement uses the wrong module name.
fix
Ensure the package is correctly installed using pip: `pip install flask-swagger-ui`. The correct import statement is `from flask_swagger_ui import get_swaggerui_blueprint`.
werkzeug.exceptions.NotFound: 404 Not Found: The requested URL was not found on the server.
This error occurs when the Flask application cannot find the configured Swagger UI endpoint or the `swagger.json` specification file, often due to an incorrect URL prefix or API URL in the `get_swaggerui_blueprint` function, or the application not being properly registered or running.
fix
Verify that `SWAGGER_URL` (the path to the Swagger UI) and `API_URL` (the path to your OpenAPI specification file) in `get_swaggerui_blueprint` are correct and accessible. Ensure the blueprint is registered with your Flask app using `app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL)`.
AttributeError: 'Blueprint' object has no attribute 'run'
This error happens when you try to call the `.run()` method directly on a Flask Blueprint object. Blueprints are meant to be registered with a Flask application instance, not run independently.
fix
Create a Flask application instance (`app = Flask(__name__)`), register your `flask-swagger-ui` blueprint with it (`app.register_blueprint(...)`), and then run the Flask application (`app.run()`).
Swagger UI static files (CSS/JS) not loading or styling is broken
The browser is failing to load the necessary CSS and JavaScript files for the Swagger UI, often resulting in 404 errors for these static resources. This can be caused by incorrect Flask static file configuration or deployment server issues where static files are not served correctly.
fix
Ensure your Flask application is configured to serve static files correctly. If using a custom static folder, verify `static_url_path` and `static_folder` in your Flask app initialization. In production, ensure your web server (e.g., Nginx, Apache) is correctly configured to serve static assets from the appropriate paths.
Upgrade
Version history
5.32.6latest on PyPI · released May 18, 2026
Audit
Dependencies
FlaskrequiredRequired for Flask blueprint integration.
Agent activity
6 hits · last 30 days
node
6
Resources