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-uiVerified import paths — ran on the pinned version, not inferred.
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.
Review the project's GitHub for recent activity. For custom features or critical bug fixes, consider forking the repository or integrating Swagger UI manually.
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.
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.
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`.
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`.
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)`.
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()`).
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.