Pydantic validation for Sanic framework
Project description
sanicpydantic
Pydantic validation for Sanic framework
Install:
pip install sanicpydantic
Example:
from pydantic import BaseModel
from sanic_pydantic import RequestValidator
validator = RequestValidator()
...
class QueryModel(BaseModel):
str_param: str
int_param: int
bool_param: bool
@app.get('/')
@validator(query_schema=QueryModel)
def get_endpoint(request, query_: QueryModel):
...
class JsonModel(BaseModel):
str_field: str
int_field: int
bool_field: bool
@app.post('/')
@validator(json_schema=JsonModel)
def post_endpoint(request, json_: JsonModel):
...
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
sanicpydantic-0.0.1.tar.gz
(2.4 kB
view hashes)
Built Distribution
Close
Hashes for sanicpydantic-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0659dfd6580209534fe01d2df13216d18f1a1ffeb4baab995f01a5e2d2928e6 |
|
MD5 | 7d59109c27c6b17c624c55290f54c3c0 |
|
BLAKE2b-256 | 5508ddfa3f29458fd21edb435776c46ef14553a69b353ff9ddcb12d7c88342c4 |