Easy OpenAPI specs and Swagger UI for your Flask API
Flasgger is a Flask extension to extract OpenAPI-Specification from all Flask views registered in your API.
Flasgger also comes with SwaggerUI embedded so you can access http://localhost:5000/apidocs and visualize and interact with your API resources.
Flasgger also provides validation of the incoming data, using the same specification it can validates if the data received as as a POST, PUT, PATCH is valid against the schema defined using YAML, Python dictionaries or Marshmallow Schemas.
Flasgger can work with simple function views or MethodViews using docstring as specification, or using @swag_from
decorator to get specification from YAML or dict and also provides SwaggerView which can use Marshmallow Schemas as specification.
Flasgger is compatible with Flask-RESTful
so you can use Resources
and swag
specifications together, take a look at restful example.
Flasgger also supports Marshmallow APISpec
as base template for specification, if you are using APISPec from Marshmallow take a look at apispec example.