falguard-0.4
توضیحات
Falcon requests validation against OpenAPI (Swagger) schema
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | falguard-0.4 |
| نام | falguard |
| نسخه کتابخانه | 0.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Remy Gwaramadze |
| ایمیل نویسنده | remy@gwaramadze.com |
| آدرس صفحه اصلی | https://github.com/gwaramadze/falguard |
| آدرس اینترنتی | https://pypi.org/project/falguard/ |
| مجوز | Apache 2.0 |
Falguard |travis| |codecov| |python-versions|
=============================================
Falguard is a Python library that provides request validation helpers for
`Falcon <https://falconframework.org/>`_ web framework. Falguard relies on Yelp's `bravado-core <https://github.com/Yelp/bravado-core>`_ library.
Features
--------
* Validation of `OpenAPI (Swagger) <http://swagger.io/specification/>`_ schema
* Error serialization compliant with `JSON:API <http://jsonapi.org/format/#error-objects>`_ specification
* Validator may be used either as a hook or a middleware component
Installation
------------
.. code:: bash
$ pip install falguard
Usage
-----
Instantiate Validator with the path to OpenAPI specification (both json and yaml are supported)...
.. code:: python
import falguard
validator = falguard.Validator('spec.json')
...and use it as the hook on the responder...
.. code:: python
class Resource:
@falcon.before(validator)
def on_get(self, request, response, **validated):
pass
...or the hook on the whole resource...
.. code:: python
@falcon.before(validator)
class Resource:
pass
...or globally, as the middleware component.
.. code:: python
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.
.. code:: python
class Resource:
def on_put(self, request, response, resource_id, data):
pass
def on_post(self, request, response, **validated):
pass
.. |travis| image:: https://travis-ci.org/gwaramadze/falguard.svg
:target: https://travis-ci.org/gwaramadze/falguard
.. |codecov| image:: https://codecov.io/gh/gwaramadze/falguard/branch/master/graph/badge.svg
:target: https://codecov.io/gh/gwaramadze/falguard
.. |python-versions| image:: https://img.shields.io/pypi/pyversions/falguard.svg
:target: https://pypi.org/project/falguard/
نیازمندی
| مقدار | نام |
|---|---|
| <3.0.0,>=1.1.0 | falcon |
| <6.0.0,>=4.6.0 | bravado-core |
| >=1.12.0 | six |
| - | pytest |
| - | pytest-cov |
| - | pytest-flake8 |
| - | pytest-pylint |
نحوه نصب
نصب پکیج whl falguard-0.4:
pip install falguard-0.4.whl
نصب پکیج tar.gz falguard-0.4:
pip install falguard-0.4.tar.gz