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
Installation
$ pip install falguard
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for falguard-0.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55976b3de9650ed8768767d0164b9c31dc4fb96cfaf0084b5d56a798e8993ce2 |
|
MD5 | 400f78c22d067b5023b643425b4c485a |
|
BLAKE2b-256 | 1939a3b52e2a678187bd53ae551dfb72478965d7528864061a3542008411b824 |