Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
/ pydantic-webargs Public archive

A library for parsing and validating http requests for Flask web framework using pydantic library

License

Notifications You must be signed in to change notification settings

nf1s/pydantic-webargs

Repository files navigation

Pyndatic Webargs

CircleCI codecov GitHub Pipenv locked Python version Downloads license

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)

About

A library for parsing and validating http requests for Flask web framework using pydantic library

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published