Skip to main content

Client and Validator of OpenAPI 3 Specifications

Project description

openapi3
========

.. highlight:: python

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

.. image:: https://travis-ci.org/Dorthu/openapi3-parser.svg?branch=master
:target: https://travis-ci.org/Dorthu/openapi3-parser


**NOTE**

This is a work in progress, and may change significantly in the future. Many
features are presently absent, and many common cases may not be implemented.

Validation Mode
---------------

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

python3 -m openapi /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

# 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.securtiySchemes
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

Roadmap
-------

The following still needs to be done:

* 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.

.. _OpenAPI 3 Specification: https://openapis.org
.. _Linode's OpenAPI 3 Specification: https://developers.linode.com/api/v4


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

openapi3-0.0.1.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

openapi3-0.0.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file openapi3-0.0.1.tar.gz.

File metadata

  • Download URL: openapi3-0.0.1.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for openapi3-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f8632c5b6ba8e47f2f86c0708bfc253c5a9747d8e4d340ec750bf15b2a6f1c35
MD5 c9536574915611a2c9ea327dd74a9906
BLAKE2b-256 15142e9d5c4809a842e98d1b03a3f9ea648524d4923b051840f61f354dbb90db

See more details on using hashes here.

File details

Details for the file openapi3-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openapi3-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 09bff310582915784ed389dd637c1045148814d4d57b3b19e7467d4020f0bef0
MD5 36c06a680f2920c5b9d7c575f034e8a3
BLAKE2b-256 2b1e7ee0ee7b98e7d185744175cae4f7eac5561a097c0e966f3f28863836de32

See more details on using hashes here.

Supported by

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