Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nf1s/pydantic-webargs
A library for parsing and validating http requests for Flask web framework using pydantic library
https://github.com/nf1s/pydantic-webargs
decorator flask flask-extension json json-parser parser pydantic web webargs
Last synced: about 2 months ago
JSON representation
A library for parsing and validating http requests for Flask web framework using pydantic library
- Host: GitHub
- URL: https://github.com/nf1s/pydantic-webargs
- Owner: nf1s
- License: mit
- Created: 2020-05-27T08:41:43.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T12:41:21.000Z (about 2 years ago)
- Last Synced: 2024-03-15T07:04:09.358Z (10 months ago)
- Topics: decorator, flask, flask-extension, json, json-parser, parser, pydantic, web, webargs
- Language: Python
- Homepage: https://ahmednafies.github.io/pydantic-webargs/
- Size: 868 KB
- Stars: 16
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Pyndatic Webargs
[![CircleCI](https://circleci.com/gh/nf1s/pydantic-webargs.svg?style=shield)](https://circleci.com/gh/nf1s/pydantic-webargs) [![codecov](https://codecov.io/gh/nf1s/pydantic-webargs/branch/master/graph/badge.svg)](https://codecov.io/gh/nf1s/pydantic-webargs) ![GitHub Pipenv locked Python version](https://img.shields.io/github/pipenv/locked/python-version/nf1s/pydantic-webargs) [![Downloads](https://pepy.tech/badge/pydantic-webargs)](https://pepy.tech/project/pydantic-webargs) ![license](https://img.shields.io/badge/license-MIT-green)A library for parsing and validating http requests for flask web-framework using pydantic library
Full documentation [here](https://nf1s.github.io/pydantic-webargs/)
## Requirements
python >= 3.7
## How to install
```bash
pip install pydantic-webargs
```## Dependencies
flask
pydantic## Example
```python
from flask import Flask
from pydantic import BaseModel
from pydantic_webargs import webargsapp = Flask(__name__)
class QueryModel(BaseModel):
name: strclass 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 responseif __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
```