flask_restful_jsonschema
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.
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"]
Metadata
Release files for flask_restful_jsonschema 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flask_restful_jsonschema-0.1.1.tar.gz | 1.9 kB | Without provenance | Details for flask_restful_jsonschema-0.1.1.tar.gz |
Release files / flask_restful_jsonschema-0.1.1.tar.gz
| Download URL | flask_restful_jsonschema-0.1.1.tar.gz |
|---|---|
| Size | 1.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c81fd18d18f70d77671c540411e0077f5ef1bc050306ac361e05b5b61b613ac
|
|
BLAKE2b-256 checksum How to use checksums |
374d7272160f8bf3ad47eb22328ddaeccf775d9a466deb0d685e16a73029f0b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for flask_restful_jsonschema 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.