Skip to main content

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 model
  • submit 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


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)

Uploaded Source

Built Distribution

pydantic_fetch-0.0.3-py3-none-any.whl (3.9 kB view hashes)

Uploaded Python 3

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