Skip to main content

Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.

Project description

Documentation Status CI Status PyPI status Code style Code of Conduct

Flask-Rebar combines flask, marshmallow, and swagger for robust REST services.


  • Request and Response Validation - Flask-Rebar relies on schemas from the popular Marshmallow package to validate incoming requests and marshal outgoing responses.
  • Automatic Swagger Generation - The same schemas used for validation and marshaling are used to automatically generate OpenAPI specifications (a.k.a. Swagger). This also means automatic documentation via Swagger UI.
  • Error Handling - Uncaught exceptions from Flask-Rebar are converted to appropriate HTTP errors.


from flask import Flask
from flask_rebar import errors, Rebar
from marshmallow import fields, Schema

from my_app import database

rebar = Rebar()

# All handler URL rules will be prefixed by '/v1'
registry = rebar.create_handler_registry(prefix='/v1')

class TodoSchema(Schema):
    id = fields.Integer()
    complete = fields.Boolean()
    description = fields.String()

# This schema will validate the incoming request's query string
class GetTodosQueryStringSchema(Schema):
    complete = fields.Boolean()

# This schema will marshal the outgoing response
class GetTodosResponseSchema(Schema):
    data = fields.Nested(TodoSchema, many=True)

    response_body_schema=GetTodosResponseSchema(), # for versions <= 1.7.0, use marshal_schema
def get_todos():
    This docstring will be rendered as the operation's description in
    the auto-generated OpenAPI specification.
    # The query string has already been validated by `query_string_schema`
    complete = rebar.validated_args.get('complete')


    # Errors are converted to appropriate HTTP errors
    raise errors.Forbidden()


    # The response will be marshaled by `marshal_schema`
    return {'data': []}

def create_app(name):
    app = Flask(name)
    return app

if __name__ == '__main__':

For a more complete example, check out the example app at examples/ Some example requests to this example app can be found at examples/


pip install flask-rebar


More extensive documentation can be found here.


Flask-Rebar is extensible! Here are some open source extensions:


There is still work to be done, and contributions are encouraged! Check out the contribution guide for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-rebar, version 1.11.0
Filename, size File type Python version Upload date Hashes
Filename, size flask-rebar-1.11.0.tar.gz (4.2 MB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page