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.2.tar.gz
(3.5 kB
view hashes)
Built Distribution
Close
Hashes for pydantic_fetch-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ae096654e5305b791eb6dcd1da7227c6f824de3c7ffa009d43093ed2a11c363 |
|
MD5 | 26cabdb8aeb961e6be65b0ff890f6b02 |
|
BLAKE2b-256 | cf70a2df681cfd7a4cb9fa12a7358676d74b78bc835c3eece1cc02b120f2d0df |