Provides a wrapper which provides valid json to Resource methods.
Project description
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.
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):
pass
@validate_json
def put(self, json_request):
pass
@validate_json
def get(self, json_request):
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for flask_restful_jsonschema-0.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28aaa82f09bc0cd1300c9c369b4bc1a83340710b321166f237ef0a3d6fa4c09d |
|
MD5 | 08f2c30a0eb1b718d2980735477c247b |
|
BLAKE2b-256 | 07eff098709dbb7ad57fee9200391fddec775f942dfe35fd6efcd293fa270156 |