Http client base pydantic, with requests or aiohttp
Project description
pydantic-client
Http client base pydantic, with requests or aiohttp
How to use
from pydantic import BaseModel
from pydantic_client import delete, get, post, put, RequestsClient
class Book(BaseModel):
name: str
age: int
class R(RequestsClient):
@get("/books/{book_id}?query={query}")
def get_book(self, book_id: int, query: str) -> Book:
...
@post("/books", form_body=True)
def create_book_form(self, book: Book) -> Book:
""" will post the form with book"""
...
@put("/books/{book_id}")
def change_book(self, book_id: int, book: Book) -> Book:
"""will put the json body"""
...
@delete("/books/{book_id}")
def change_book(self, book_id: int) -> Book:
...
my_client = R("http://localhost/v1")
get_book: Book = my_client.get_book(1)
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_client-0.1.4.tar.gz
(7.7 kB
view details)
Built Distribution
File details
Details for the file pydantic_client-0.1.4.tar.gz
.
File metadata
- Download URL: pydantic_client-0.1.4.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.10.9 Darwin/19.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbdefd9becbf709b0fc65648f62729768edb931c0422e8f024772a53c3005710 |
|
MD5 | bb6542372554bbdd6f05577f0e9130c3 |
|
BLAKE2b-256 | c9949338d95673b01962714f2ea951cec85a6257e17848d6a04e991f17ba74e0 |
Provenance
File details
Details for the file pydantic_client-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: pydantic_client-0.1.4-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.4.0 CPython/3.10.9 Darwin/19.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a3dbba7a57fdf0a290ff983777245cbf95fbf3b13160fb19de787761b37f95a |
|
MD5 | e02bb1b3c788ffb604be9cac6f759057 |
|
BLAKE2b-256 | e4a2565a1507ec6ad91db08f46b95e15280953d671dbb406442ce8d9189a6bc5 |