autodocumentation

Autodocumention is generated via a swagger spec: swagger. It is generated by instatiating a swagger object, then using the “init_app” method:

from flask_transmute.swagger import Swagger
from flask import Flask

route_set = flask_transmute.FlaskRouteSet()

@route_set.route("/api/is_programming_fun")
def is_programming_fun(language: str) -> bool:
    """
    given a language, return True if programming
    in that language is fun.
    """
    return language.lower() == "python"


app = Flask(__name__)
route_set.init_app(app)
swagger = Swagger("myApi", "1.0", route_prefix="/api")
swagger.init_app(app)

init_app will attach two routes:

  • <route_prefix>, which will be a swagger ui page with your route documentation.
  • <route_prefix>/swagger.json, which will be the swagger spec itself.