nikitagashkov / openapi-core

OpenAPI core

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

openapi-core

image

image

image

image

image

image

About

Openapi-core is a Python library that adds client-side and server-side support for the OpenAPI Specification v3.0.0.

Installation

Recommended way (via pip):

$ pip install openapi-core

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

Usage

Firstly create your specification:

Request

Now you can use it to validate requests

and unmarshal request data from validation result

Request object should be instance of OpenAPIRequest class (See Integrations).

Response

You can also validate responses

and unmarshal response data from validation result

Response object should be instance of OpenAPIResponse class (See Integrations).

Security

openapi-core supports security for authentication and authorization process. Security data for security schemas are accessible from security attribute of RequestValidationResult object.

For given security specification:

you can access your security data the following:

Supported security types:

  • http – for Basic and Bearer HTTP authentications schemes
  • apiKey – for API keys and cookie authentication

Customizations

Deserializers

Pass custom defined media type deserializers dictionary with supported mimetypes as a key to RequestValidator or ResponseValidator constructor:

Integrations

Django

For Django 2.2 you can use DjangoOpenAPIRequest a Django request factory:

You can use DjangoOpenAPIResponse as a Django response factory:

Flask

Decorator

Flask views can be integrated by FlaskOpenAPIViewDecorator decorator.

If you want to decorate class based view you can use the decorators attribute:

View

As an alternative to the decorator-based integration, Flask method based views can be integrated by inheritance from FlaskOpenAPIView class.

Request parameters

In Flask, all unmarshalled request data are provided as Flask request object's openapi.parameters attribute

Low level

You can use FlaskOpenAPIRequest a Flask/Werkzeug request factory:

You can use FlaskOpenAPIResponse as a Flask/Werkzeug response factory:

Pyramid

See pyramid_openapi3 project.

About

OpenAPI core

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Python 99.8%Language:Makefile 0.2%