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 (both json and yaml are supported)…
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size falguard-0.3-py2.py3-none-any.whl (4.0 kB) | File type Wheel | Python version py2.py3 | Upload date | Hashes View |
Filename, size falguard-0.3.tar.gz (3.3 kB) | File type Source | Python version None | Upload date | Hashes View |
Close
Hashes for falguard-0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6921d27e69e8077e16e5dd67dbd39fc8683190c8183dab6fc7bcf5013a6df13 |
|
MD5 | 93a91461bb828918d9cb8588f8fbe2b3 |
|
BLAKE2-256 | 0d3c98b743ea38c213757d3dbfeabab0544090ffbf855a3de2bd33a6dc5a6a20 |