Skip to main content

A library for generating web API clients from OpenAPI documents

Project description

oapi

test PyPI version

oapi is a library for authoring python client libraries for web APIs based on an OpenAPI specification (both OpenAPI/Swagger version 2 and version 3 are supported).

oapi-generated packages/modules differ from those generated by other tools (including but not limited to swagger-codegen) in that oapi generates a data model which enforces the schemas defined in the OpenAPI specification. This means that request and response objects, and their properties/items/members, cannot comprise data types which differ from those specified in their OpenAPI document. Additionally, request and response objects can be validated using sob.validate to verify that they were not parsed from an object having attributes not defined in the element's JSON schema, and have all required attributes. oapi fully supports polymorphism when a schema has an "anyOf", "allOf", or "oneOf" attribute (although oapi does not require a discriminator to be defined).

Notable features of an oapi generated client/model library include:

  • oapi generated data models and clients are fully type-annotated
  • oapi generated data models and clients adhere to PEP-8 formatting
  • oapi generated data models and clients include docstrings for all models, model properties, client methods, and client method parameters, inferred from "description" and "summary" attributes of elements within the specification
  • oapi generated clients will handle the most common server-to-server authentication methods out-of-box, including the OAuth2 authorization code flow (client_id/client_secret), API keys, bearer tokens, HTTP basic auth, and most cookie-based authentication patterns. Custom authentication methods are also easily accomplished by specifying custom base classes and/or passing initialization decorators to oapi.write_client_module.
  • oapi generated clients and models are easily updated. For instance: oapi generated data model classes can be renamed using your favorite IDE's refactoring tools, and subsequent updates to that data model (such as to reflect minor-version updates to the spec which add endpoints, schemas, parameters, etc.) will retain your new class names, so long as the schema from which the class was generated remains in the same location within the spec. Class naming can also be customized by passing a custom hook to the get_class_name_from_pointer parameter for oapi.write_model_module.

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

oapi-2.8.7.tar.gz (67.5 kB view details)

Uploaded Source

Built Distribution

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

oapi-2.8.7-py3-none-any.whl (71.7 kB view details)

Uploaded Python 3

File details

Details for the file oapi-2.8.7.tar.gz.

File metadata

  • Download URL: oapi-2.8.7.tar.gz
  • Upload date:
  • Size: 67.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for oapi-2.8.7.tar.gz
Algorithm Hash digest
SHA256 38774ef85df27b782d734b7c294549a551f1b82461db71d7a5c4efe25c10f38b
MD5 d348464b5f6de33fbd90d8c5b73d3aa5
BLAKE2b-256 830ebbca9d8642536d95b7b2b86db98713c05829a3d26e5bde4da53e38cfd4c2

See more details on using hashes here.

File details

Details for the file oapi-2.8.7-py3-none-any.whl.

File metadata

  • Download URL: oapi-2.8.7-py3-none-any.whl
  • Upload date:
  • Size: 71.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.5 cpython/3.12.3 HTTPX/0.28.1

File hashes

Hashes for oapi-2.8.7-py3-none-any.whl
Algorithm Hash digest
SHA256 c31a7f4d42a5dadc8b9e8a2a30c1c8b498b84f0fd7aa4b4ff129dbffb3f2cf05
MD5 517231d61f2a4044ffe9a59c1c82956a
BLAKE2b-256 1b57b4f709d67d6575551a9a4709c9ff19b984623179022de18de6cdf5311638

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