Skip to main content

openapi3

This project is forked from https://github.com/Dorthu/openapi3 Additional capabilities added on top of it

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

GitHub Actions Build Badge https://badge.fury.io/py/openapi3.svg

Validation Mode

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

python3 -m openapi3 /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 openapi3 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 opertaion 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.

Metadata

Release files for openapi3v1 0.0.2

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

Source distribution (sdist)

Source distribution for openapi3v1 0.0.2
File Size Uploaded Provenance Actions
openapi3v1-0.0.2.tar.gz 21.8 kB Without provenance Details for openapi3v1-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openapi3v1 0.0.2
File Interpreter ABI Platform Actions
openapi3v1-0.0.2-py3-none-any.whl Python 3 none any Details for openapi3v1-0.0.2-py3-none-any.whl

Total release size: 48.4 kB

Release files / openapi3v1-0.0.2.tar.gz

Download URL openapi3v1-0.0.2.tar.gz
Size 21.8 kB
Tags Source
SHA-256 checksum
How to use checksums
577bf91f487a7e9d3ff340be2c06b493509abd8745a85cd48c97d853675d1cdb
BLAKE2b-256 checksum
How to use checksums
7636aeff4c9736c6dbe7743d77ef1d4cc51b6b732b4c19754e38d1defbc27ec1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.8rc1

Release files / openapi3v1-0.0.2-py3-none-any.whl

Download URL openapi3v1-0.0.2-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46bc146205729a0d79b3be28d62fa3d915a9500f8bddec3c7a22a96b7705b8b4
BLAKE2b-256 checksum
How to use checksums
d83acb4caef8cb1c848d0f31f1b8208f8bf4e85e5ec9beeb0ca4a80541fa324b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.7.8rc1

Security for openapi3v1 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

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