Skip to main content

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

oas_client-0.1.5.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oas_client-0.1.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file oas_client-0.1.5.tar.gz.

File metadata

  • Download URL: oas_client-0.1.5.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for oas_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 639dbea377f12475fb61086af842391120e4b3d8348055385ecf238f0b9d6da8
MD5 b1f94f02a075cdbd6e8625716bb76738
BLAKE2b-256 5dbd9ab040c98392881eed9347d6b299770725c3ee2a71937fe3886f18b8b9b9

See more details on using hashes here.

File details

Details for the file oas_client-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: oas_client-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for oas_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f68dd2d3a55d8c1afcfa88c754584799cd88778c83af611daedc509b763fe7cb
MD5 4662ff3bb0e847cd3746a51e1aca039e
BLAKE2b-256 04b613876372ffaf50ba564a4acc04a0649e296bdce5fa3e9b6a1cab38745f3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page