Skip to main content

A Python OpenAPI 3 Specification client and validator for Python 3.

Validation Mode

This module can be run against a spec file to validate it like so:

python3 -m asyncopenapi3 /path/to/spec

Usage as a Client

This library also functions as an interactive client for arbitrary OpenAPI 3 specs. For example, using Linode’s OpenAPI 3 Specification for reference:

from asyncopenapi3 import OpenAPI
import yaml

# load the spec file and read the yaml
with open('openapi.yaml') as f:
    spec = yaml.safe_load(f.read())

# parse the spec into python - this will raise if the spec is invalid
api = OpenAPI(spec)

# call operations and receive result models
regions = api.call_getRegions()

# authenticate using a securityScheme defined in the spec's components.securitySchemes
api.authenticate('personalAccessToken', my_token)

# call an operation that requires authentication
linodes  = api.call_getLinodeInstances()

# call an operation with parameters
linode = api.call_getLinodeInstance(parameters={"linodeId": 123})

# the models returns are all of the same (generated) type
print(type(linode))                      # openapi.schemas.Linode
type(linode) == type(linodes.data[0])    # True

# call an operation with a request body
new_linode = api.call_createLinodeInstance(data={"region":"us-east","type":"g6-standard-2"})

# the returned models is still of the correct type
type(new_linode) == type(linode)     # True

HTTP basic authentication and HTTP digest authentication works like this:

# authenticate using a securityScheme defined in the spec's components.securitySchemes
# Tuple with (username, password) as second argument
api.authenticate('basicAuth', ('username', 'password'))

Running Tests

This project includes a test suite, run via pytest. To run the test suite, ensure that you’ve installed the dependencies and then run pytest in the root of this project.

Roadmap

The following features are planned for the future:

  • Request body models, creation, and validation.

  • Parameters interface with validation and explicit typing.

  • Support for more authentication types.

  • Support for non-json request/response content.

  • Full support for all objects defined in the specification.

Release files for asyncopenapi3 1.8.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for asyncopenapi3 1.8.2.1
File Size Uploaded
asyncopenapi3-1.8.2.1.tar.gz 44.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for asyncopenapi3 1.8.2.1
File Interpreter ABI Platform
asyncopenapi3-1.8.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 96.8 kB

Release files / asyncopenapi3-1.8.2.1.tar.gz

Download URL asyncopenapi3-1.8.2.1.tar.gz
Size 44.7 kB
Tags Source
SHA-256 checksum
How to use checksums
687fd1e0cbcc6144df1f522d1669406fb3338d885f668af2107f3cd59729458d
BLAKE2b-256 checksum
How to use checksums
a21ffebc170644f3bc664b0e2e61a9e461b1ee344bfe8c45e8555f00ecef857a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / asyncopenapi3-1.8.2.1-py2.py3-none-any.whl

Download URL asyncopenapi3-1.8.2.1-py2.py3-none-any.whl
Size 52.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
e5b8f4a55f7e3108c2a922cdd5cc8f1ee1cd88b6e2399d42c41b86ca6aaaa9fa
BLAKE2b-256 checksum
How to use checksums
4ca8ed617642bd97bcc3212def02dbe02d10badb2d9cae451fe69b9db2015056
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

1.8.2.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page