Falcon requests validation against OpenAPI (Swagger) schema
$ pip install falguard
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
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Hashes for falguard-0.4-py2.py3-none-any.whl