Pyndatic Webargs
A library for parsing and validating http requests for flask web-framework using pydantic library
Full documentation here
Requirements
python >= 3.7
How to install
pip install pydantic-webargs
Dependencies
flask
pydantic
Example
from flask import Flask
from pydantic import BaseModel
from pydantic_webargs import webargs
app = Flask(__name__)
class QueryModel(BaseModel):
name: str
class BodyModel(BaseModel):
age: int
@app.route("/get-request", methods=["GET"])
@webargs(query=QueryModel)
def example_get_endpoint(**kwargs):
response = kwargs
return response
@app.route("/post-request", methods=["POST"])
@webargs(query=QueryModel, body=BodyModel)
def example_post_endpoint(**kwargs):
print(kwargs)
response = kwargs
return response
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Release files for pydantic-webargs 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydantic_webargs-1.1.0.tar.gz | 3.2 kB | Details |
Release files / pydantic_webargs-1.1.0.tar.gz
| Download URL | pydantic_webargs-1.1.0.tar.gz |
|---|---|
| Size | 3.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bd74d84e4a1956cd2ce3ba5957c6f652cde861f44c2c9927fe5b8b011c29e713
|
|
BLAKE2b-256 checksum How to use checksums |
86fe4a7607a2fe487304ada95523aee040cc40bb39d624192f08e6375f5fd88b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/1.7.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12
|