Generate typed python client from OpenAPI specification
Project description
oas-client
Generate typed python client from OpenAPI specification
Installation
You can install the package via pip:
pip install oas-client
Usage
Use this command to generate client.
oas-client <path_or_url>
To use the generate client,
from client.client import APIClient
client = APIClient(
base_url="https://api.example.com",
headers={
"Authorization": "Bearer MY_SECRET_TOKEN",
},
# supports all configurations from httpx.Client
)
print(
client.core_api_list_servers(
follow_redirects=False,
timeout=10,
# supports all configurations from httpx request
)
)
Why not pydantic?
Request bodies are meant to support partial data, especially in PATCH requests, which is not supported by pydantic model. So, we use TypedDict with NotRequired modifier.
class PartialUpdateAccountSchema(TypedDict):
email: NotRequired[str]
address: NotRequired[str]
country: NotRequired[str]
dob: NotRequired[str]
Why duplicate schemas in requests.py and responses.py?
There is a possibility of duplicate schemas for request body and reponse body because NotRequired modifier is necessary for only request body and is not relevant for respose body.
Limitations
- Only supports OAS 3
- No aysnc support
License
This project is licensed under the terms of the MIT license.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oas_client-0.1.7.tar.gz.
File metadata
- Download URL: oas_client-0.1.7.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df205042c1e98569b713373db7d24fa0ac042864b3613ddac6f5409ec5d1ad7b
|
|
| MD5 |
88e2c5590585b2932e97c1e214a20852
|
|
| BLAKE2b-256 |
27dc7adcdd98bf648ca845226b704b1b1c0b701c00254d28ead32cabf8c18f7d
|
File details
Details for the file oas_client-0.1.7-py3-none-any.whl.
File metadata
- Download URL: oas_client-0.1.7-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8fca714861f480507b9bbf6db903a575b61465cbef2b9c8ff8a78648688bb3c8
|
|
| MD5 |
6f20694859051b04338c665a9329a326
|
|
| BLAKE2b-256 |
c515423780e0af44eb9b2b96565f19fd830800522622c46d78ccab191eafe055
|