Skip to main content

client-side and server-side support for the OpenAPI Specification v3

Project description

https://img.shields.io/pypi/v/openapi-core.svg https://travis-ci.org/python-openapi/openapi-core.svg?branch=master https://img.shields.io/codecov/c/github/python-openapi/openapi-core/master.svg?style=flat https://img.shields.io/pypi/pyversions/openapi-core.svg https://img.shields.io/pypi/format/openapi-core.svg https://img.shields.io/pypi/status/openapi-core.svg

About

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI v3.0 and OpenAPI v3.1 specification.

Key features

  • Validation and unmarshalling of request and response data (including webhooks)

  • Integration with popular libraries (Requests, Werkzeug) and frameworks (Django, Falcon, Flask, Starlette)

  • Customization with media type deserializers and format unmarshallers

  • Security data providers (API keys, Cookie, Basic and Bearer HTTP authentications)

Documentation

Check documentation to see more details about the features. All documentation is in the “docs” directory and online at openapi-core.readthedocs.io

Installation

Recommended way (via pip):

pip install openapi-core

Alternatively you can download the code and install from the repository:

pip install -e git+https://github.com/python-openapi/openapi-core.git#egg=openapi_core

First steps

Firstly create your specification object.

from openapi_core import Spec

spec = Spec.from_file_path('openapi.json')

Now you can use it to validate and unmarshal against requests and/or responses.

from openapi_core import unmarshal_request

# raises error if request is invalid
result = unmarshal_request(request, spec=spec)

Retrieve validated and unmarshalled request data

# get parameters
path_params = result.parameters.path
query_params = result.parameters.query
cookies_params = result.parameters.cookies
headers_params = result.parameters.headers
# get body
body = result.body
# get security data
security = result.security

Request object should implement OpenAPI Request protocol. Check Integrations to find oficially supported implementations.

For more details read about Unmarshalling process.

If you just want to validate your request/response data without unmarshalling, read about Validation instead.

License

The project is under the terms of BSD 3-Clause License.

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

openapi_core-0.17.0.tar.gz (44.9 kB view details)

Uploaded Source

Built Distribution

openapi_core-0.17.0-py3-none-any.whl (86.1 kB view details)

Uploaded Python 3

File details

Details for the file openapi_core-0.17.0.tar.gz.

File metadata

  • Download URL: openapi_core-0.17.0.tar.gz
  • Upload date:
  • Size: 44.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1033-azure

File hashes

Hashes for openapi_core-0.17.0.tar.gz
Algorithm Hash digest
SHA256 ab7dd9deafa1a8627104bbf7d4f635583e0348552fa1819c60e3167f336524cd
MD5 5c018f6627ce544f86bae840369793be
BLAKE2b-256 ec779f8f4fbffb35e49d03209360db082b25652e45a40bf7e4dda7e0f1edd4fc

See more details on using hashes here.

File details

Details for the file openapi_core-0.17.0-py3-none-any.whl.

File metadata

  • Download URL: openapi_core-0.17.0-py3-none-any.whl
  • Upload date:
  • Size: 86.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.0 CPython/3.11.2 Linux/5.15.0-1033-azure

File hashes

Hashes for openapi_core-0.17.0-py3-none-any.whl
Algorithm Hash digest
SHA256 407a49f986e5a452a5bfb7a04300fc551e036615891017ce9d694b2205f2811f
MD5 6a51caaf709021282c8871e6df85e7dd
BLAKE2b-256 48954a5cd061a0b576d780a0c989896b8cd50903e518c7fce9050044b7f04ce0

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