Skip to content
Flask + schema = cazart!
Python Makefile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
src/cazart
test
.flake8
.gitignore
.travis.yml
Makefile
README.md
pyproject.toml
setup.py

README.md

cazart

Build Status

Flask + schema = cazart!

cazart is a small helper for writing schematized JSON endpoints with Flask. It rolls schema into Flask's route decorator, allowing for one-shot route and schema specification.

Installation

cazart requires Python 3.6 or newer.

pip3 install cazart

Usage

To use cazart, just swap your Flask instance out for a Cazart one:

from cazart import Cazart

app = Cazart(__name__)

You can access all of Flask's baseline functionality (including non-validated routes) via app.flask.

Then, use app.route to specify a combination route and schema:

from cazart import Cazart
from schema import Schema, Or

app = Cazart(__name__)


@app.route("/cazart", schema=Schema({"name": Or("alice", "bob", "mary")}))
def cazart(res):
    print(f"my verified payload is {res}!")
    return ("ok", 200)

See the examples for full usage examples, including custom error handling and dispatching to different schemas on a route based on HTTP method.

You can’t perform that action at this time.