flask-swagger
Extract swagger specs from your flask project
What it is and what it does
flask-swagger is a documentation extraction tool that reads YAML docstrings embedded in Flask view functions and MethodView methods, then generates a Swagger 2.0 specification object. It parses the YAML following a convention where content before `---` becomes the endpoint summary and description, and content after becomes the Operation object (parameters, responses, schemas, tags). The tool supports inline schema definitions with an `id` field that get collected into a definitions section, and handles nested schemas within properties.
You use it by calling the `swagger()` function on your Flask app to generate a spec dictionary, which you then expose via a Flask route (typically `/spec`) and serve to Swagger UI or other documentation consumers. The spec returned is minimal—you're expected to augment it with metadata like API title and version. The package depends only on Flask and PyYAML, making installation straightforward, but it has been unmaintained since 2019 and is unlikely to receive updates for newer Swagger or Flask versions.
Use it for:
- Generate Swagger 2.0 documentation from existing Flask endpoints without writing separate spec files
- Serve API specs to Swagger UI for interactive API exploration and testing
- Export Flask API contracts for client code generation or third-party integrations
- Document MethodView-based REST APIs by embedding operation details in docstrings
- Build minimal API documentation endpoints that reflect your current Flask routes
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Extracts Swagger 2.0 API specifications from Flask applications by parsing YAML docstrings in view functions and MethodView classes.
No—unless you are maintaining legacy code already using this package. The project is abandoned (last release 2019, last commit 2021) with no active maintenance. For new projects, use actively maintained alternatives like Flask-RESTX, Flasgger, or Connexion that support modern OpenAPI 3.0 specs and receive regular updates. The low install friction and permissive license do not offset the risk of relying on unmaintained code.
Install
flask-swagger on PyPI
pip
pip install flask-swaggeruv
uv add flask-swaggerpoetry
poetry add flask-swaggerInstalling flask-swagger
Before you install
Low install friction with only Flask and PyYAML as runtime dependencies. However, the package is abandoned—last release was 2019-03-26 and last commit 2021-11-18. No active maintenance means security updates and compatibility fixes are unlikely.
License in practice
MIT license is permissive and imposes minimal restrictions; you can use, modify, and distribute the package freely with attribution.
Quickstart
pip install flask-swagger
from flask import Flask, jsonify
from flask_swagger import swagger
app = Flask(__name__)
@app.route("/spec")
def spec():
return jsonify(swagger(app))
Verify before relying
- Whether the package works reliably with modern Flask and PyYAML versions given its abandoned status
- Compatibility with Python versions beyond 3.4 (classifiers list 3.4 but no requires_python constraint)
- Whether Swagger 2.0 spec extraction meets current OpenAPI/Swagger UI expectations
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — Flask, PyYAML |
| Maintenance | abandoned — 2,698 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 151,808/month — #10,920 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: flask_swagger-0.2.14-py2-none-any.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flasggerFlasgger extracts OpenAPI specifications from…
permissive · top 5,000 on PyPI
flask-swagger-uiAdds Swagger UI to Flask applications as a…
permissive · top 5,000 on PyPI
swagger-ui-pyIntegrates Swagger UI documentation into Python…
permissive · top 15,000 on PyPI
swagger-ui-bundlePackages Swagger UI's static files and…
permissive · top 5,000 on PyPI
drf-yasgGenerates Swagger/OpenAPI 2.0 specifications…
permissive · top 5,000 on PyPI
swagger-spec-validatorValidates Swagger/OpenAPI specifications…
permissive · top 15,000 on PyPI
flask-apispecflask-apispec decorates Flask view functions…
permissive · top 15,000 on PyPI
flask-restplusFlask-RESTPlus adds decorators and tools to…
permissive · top 15,000 on PyPI
flask-pydantic-specAdds OpenAPI documentation generation and…
unclear · top 15,000 on PyPI
flask-restxFlask-RESTX extends Flask with decorators and…
permissive · top 5,000 on PyPI