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.2.tar.gz
(7.7 kB
view details)
Built Distribution
File details
Details for the file pydantic_client-0.1.2.tar.gz
.
File metadata
- Download URL: pydantic_client-0.1.2.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 | 42552b7a44f9fbf88582b2b6d74bfa14b4a7fbb5fcb44e96954064376dce1bb8 |
|
MD5 | 9470eb6b646cb6954b90a1e07beb2b15 |
|
BLAKE2b-256 | 36717bd565392027277c1ce93e7a77cbf59dbe60cf5a4f6a27eb0b989bd1a325 |
Provenance
File details
Details for the file pydantic_client-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: pydantic_client-0.1.2-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 | 3a7be2a506025ba45f0d084a5855a9283116bacbfab20f6446f14d4b8e0b5c8c |
|
MD5 | 842ae5366f3d575422e19d4f35331ba3 |
|
BLAKE2b-256 | 67eeee7da4248d6e3a1a1f8108df01147ccab6814eb2105345e8e99b18a5094b |