flake8-flask-openapi-docstring

A Flake8 plugin to enforce OpenAPI docstrings in Flask routes


License
MIT
Install
pip install flake8-flask-openapi-docstring==0.1.2

Documentation

flake8-flask-openapi-docstring

This Flake8 plugin will check if your Flask route's docstrings are valid OpenAPI spec.

Libraries like APISpec can generate OpenAPI spec from your Flask routes and docstrings and it's important to have present and in the correct format.

for example, this routes:

@app.route("/hello", methods=["GET"])
def hello():
    return "Hello World!"

will raise an error witht his plugin because not only the docstring is missing but also the OpenAPI spec is missing as well.

However these route:

@app.route("/hello", methods=["GET"])
def hello():
    """
    Returns a greeting

    ---
    get:
        responses:
            200:
    """
    return "Hello World!"

will not raise any error because the docstring is present and the OpenAPI spec is present as well.