Skip to main content

Pydatic webargs

Project description

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydantic_webargs-1.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file pydantic_webargs-1.1.0.tar.gz.

File metadata

  • Download URL: pydantic_webargs-1.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for pydantic_webargs-1.1.0.tar.gz
Algorithm Hash digest
SHA256 bd74d84e4a1956cd2ce3ba5957c6f652cde861f44c2c9927fe5b8b011c29e713
MD5 5abe85b2bcf5afef475576e9797e8a70
BLAKE2b-256 86fe4a7607a2fe487304ada95523aee040cc40bb39d624192f08e6375f5fd88b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page