flask_restful_jsonschema-0.1.1
توضیحات
Provides a wrapper which provides valid json to Resource methods.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | flask_restful_jsonschema-0.1.1 |
| نام | flask_restful_jsonschema |
| نسخه کتابخانه | 0.1.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Lily Seabreeze |
| ایمیل نویسنده | lillian.gardenia.seabreeze@gmail.com |
| آدرس صفحه اصلی | UNKNOWN |
| آدرس اینترنتی | https://pypi.org/project/flask_restful_jsonschema/ |
| مجوز | MIT |
``flask_restful_jsonschema``
============================
|PyPI Version|
Add the ``@validate_json`` decorator and schema class constant to
``flask_restful.Resource`` methods (post, get, etc.) in order to
validate requests meet the ``jsonschema``.
Ensure JSON request matches schema specified in the class the wrapped
method belongs to, provide that valid JSON to the method, or abort 400
with the validation error message.
.. code:: python
from flask_restful_jsonschema import validate_json
class Users(flask_restful.Resource):
SCHEMA_POST = {
"type": "object",
"properties": {
"email": {"type": "string"},
"password": {"type": "string"},
},
"required": ["email", "password"],
}
SCHEMA_PUT = {
"type": "object",
"properties": {
"email": {"type": "string"},
"password": {"type": "string"},
},
}
SCHEMA_GET = {
"type": "object",
"properties": {
"email": {"type": "string"},
},
"required": ["email"],
}
@validate_json
def post(self, json_request):
json_request["email"]
json_request["password"]
@validate_json
def put(self, json_request):
json_request.get("email")
json_request.get("password")
@validate_json
def get(self, json_request):
json_request["email"]
.. |PyPI Version| image:: https://img.shields.io/pypi/v/flask_restful_jsonschema.svg?style=flat-square
:target: https://pypi.python.org/pypi/flask_restful_jsonschema/
نحوه نصب
نصب پکیج whl flask_restful_jsonschema-0.1.1:
pip install flask_restful_jsonschema-0.1.1.whl
نصب پکیج tar.gz flask_restful_jsonschema-0.1.1:
pip install flask_restful_jsonschema-0.1.1.tar.gz