Skip to main content

Falcon requests validation against OpenAPI (Swagger) schema

Project description

Falguard is a Python library that provides request validation helpers for Falcon web framework. Falguard relies on Yelp’s bravado-core library.

Features

  • Validation of OpenAPI (Swagger) schema
  • Error serialization compliant with JSON:API specification
  • Validator may be used either as a hook or a middleware component

Usage

Instantiate Validator with the path to OpenAPI specification…

import falguard

validator = falguard.Validator('spec.json')

…and use it as the hook on the responder…

class Resource:

    @falcon.before(validator)
    def on_get(self, request, response, **validated):
        pass

…or the hook on the whole resource…

@falcon.before(validator)
class Resource:
    pass

…or globally, as the middleware component.

import falcon

api = falcon.API(middleware=validator)

All validated parameters (path, query, body) are injected back to the responder so it MUST accept relevant number of arguments, eg.

class Resource:

    def on_put(self, request, response, resource_id, data):
        pass

    def on_post(self, request, response, **validated):
        pass

Project details


Release history Release notifications

This version
History Node

0.1

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
falguard-0.1.tar.gz (2.7 kB) Copy SHA256 hash SHA256 Source None Jul 16, 2017

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 DigiCert DigiCert EV certificate StatusPage StatusPage Status page