Flasgger

0.9.7.1 · active · verified Sat Apr 11

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.

Warnings

Install

Imports

Quickstart

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.

from flask import Flask, jsonify
from flasgger import Swagger

app = Flask(__name__)
swagger = Swagger(app)

@app.route("/hello")
def hello_world():
    """
    Hello World! endpoint.
    ---    
    responses:
      200:
        description: A simple hello world message
    """
    return jsonify(hello="world")

if __name__ == "__main__":
    app.run(debug=True)

view raw JSON →