{"id":4009,"library":"flasgger","title":"Flasgger","description":"Flasgger is a Python library that integrates Swagger UI into Flask applications, automatically extracting Swagger/OpenAPI specifications from docstrings within your Flask project's endpoints. The current version is 0.9.7.1, with development continuing through beta releases and stable updates to address compatibility and new features.","status":"active","version":"0.9.7.1","language":"en","source_language":"en","source_url":"https://github.com/flasgger/flasgger/","tags":["flask","swagger","openapi","documentation","api","rest"],"install":[{"cmd":"pip install flasgger","lang":"bash","label":"Install Flasgger"}],"dependencies":[{"reason":"Core web framework integration.","package":"Flask","optional":false},{"reason":"Used for parsing YAML specifications.","package":"PyYAML","optional":false},{"reason":"Used for JSON schema validation.","package":"jsonschema","optional":false},{"reason":"Library for generating OpenAPI specifications.","package":"apispec","optional":false},{"reason":"Provides the static files for Swagger UI.","package":"swagger_ui_bundle","optional":false}],"imports":[{"symbol":"Swagger","correct":"from flasgger import Swagger"},{"note":"Decorator used to reference a separate YAML file for Swagger specs.","symbol":"swag_from","correct":"from flasgger import swag_from"}],"quickstart":{"code":"from flask import Flask, jsonify\nfrom flasgger import Swagger\n\napp = Flask(__name__)\nswagger = Swagger(app)\n\n@app.route(\"/hello\")\ndef hello_world():\n    \"\"\"\n    Hello World! endpoint.\n    ---    \n    responses:\n      200:\n        description: A simple hello world message\n    \"\"\"\n    return jsonify(hello=\"world\")\n\nif __name__ == \"__main__\":\n    app.run(debug=True)","lang":"python","description":"This quickstart demonstrates how to initialize Flasgger with a Flask app and document a simple endpoint using a docstring. Once run, navigate to `/apidocs` in your browser to see the generated Swagger UI."},"warnings":[{"fix":"Upgrade to Python 3.x or pin Flasgger version to 0.9.4 or earlier for Python 2 projects.","message":"Flasgger versions 0.9.5 and newer officially dropped support for Python 2. Projects still on Python 2 must use Flasgger 0.9.4 or older.","severity":"breaking","affected_versions":"<0.9.5"},{"fix":"Upgrade Flasgger to at least 0.9.7b1 (or the latest stable) if using Flask 2.3 or newer.","message":"Incompatibility with Flask 2.3+ was resolved in Flasgger 0.9.7b1 (and subsequent releases like 0.9.7.1). Older Flasgger versions may experience issues with Flask's JSON encoder changes.","severity":"breaking","affected_versions":"0.9.5 - 0.9.6b1"},{"fix":"Review and update your Swagger specifications to use `#/components/schemas` for reusable data models when `config['SWAGGER']['openapi'] = '3.0.0'` is set.","message":"When migrating to OpenAPI 3.0.0, Flasgger (from 0.9.6b1) will move top-level `#/definitions` to `#/components/schemas`. Existing Swagger 2.0 specifications might require updates to match the OpenAPI 3 structure.","severity":"gotcha","affected_versions":"0.9.6b1 and newer when using OpenAPI 3"},{"fix":"If encountering dependency resolution issues, check the `apispec` and `jsonschema` versions installed and consider using virtual environments or dependency pinning.","message":"Flasgger 0.9.4 updated its supported versions for `apispec` (to 2.0.2) and `jsonschema` (to >=3.0.1). Ensure these dependencies are compatible with other libraries in your project to avoid conflicts.","severity":"gotcha","affected_versions":"0.9.4 and newer"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}