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.6.tar.gz (9.2 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.6-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: oas_client-0.1.6.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

Hashes for oas_client-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c6431c92dcd7f3add823d7aed3029a7dea56500a4affb521ad60217b2b89e520
MD5 19c1ef252870567dc54c68bb022edf99
BLAKE2b-256 d89157a33feb220918a945caf9902536f1871038c013d9dd63f4b960dc01ad7d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: oas_client-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 11.7 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d60d7815e77ff6c3417d50f0f482dd020cc6d8a04152c9b2894d315c80b8531e
MD5 52367679cd5da12f2d9f4905ccf5cba0
BLAKE2b-256 1885169490095c19a2b69224d8f30dce8828e40694a560c727e1c4811abbb474

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