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.3.tar.gz
(3.6 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_fetch-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41594fced7e6ea5fd549993c59b95fed6de03b4b35c24a0fd0ec9feffc4b9bf9 |
|
MD5 | e3a1e0da80ee111977ae0cb36cc3683b |
|
BLAKE2b-256 | 0097a567940d9c5f6a58b54d0b24e315d81612a9dd06345e297ad69a26348f3c |