Extension of pydantic models for HTTP send/recieve
Project description
Pydantic-fetch
Extension of pydantic.BaseModel
which supports sending and parsing from HTTP endpoints.
Description
BaseModel
is extended with two class functions:
fetch
to recieve a json payload from an endpoint and validate it as the pydantic modelsubmit
to send a pydantic model to an endpoint as a json payload.
Usage
from pydantic_fetch import BaseModel
class User(BaseModel):
id: str
name: str
def send_user(endpoint, id: str, name: str):
user = User(id=id, name=name)
user.submit(endpoint)
def get_user(endpoint):
user = User.fetch(endpoint)
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
pydantic-fetch-0.0.1.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_fetch-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 812bd0ab177df695c86b1f8205316aad4ac4e7d74d0d868f218aa8e9e76b624b |
|
MD5 | 51d3d912436b18b13c0580b691aab863 |
|
BLAKE2b-256 | 5cfc5b0c84961f0746bbbdc20f7c7ff1fd6e1ddaa3d366bb1e889a10823a6a0d |