connexion.apis.aiohttp_api

This module defines an AioHttp Connexion API which implements translations between AioHttp and Connexion requests / responses.

Module Contents

Classes

AioHttpApi

Defines an abstract interface for a Swagger API

Functions

problems_middleware(request, handler)

Attributes

logger

connexion.apis.aiohttp_api.logger
async connexion.apis.aiohttp_api.problems_middleware(request, handler)
class connexion.apis.aiohttp_api.AioHttpApi(*args, **kwargs)

Bases: connexion.apis.abstract.AbstractAPI

Defines an abstract interface for a Swagger API

Parameters:
  • validator_map (dict) – Custom validators for the types “parameter”, “body” and “response”.

  • resolver – Callable that maps operationID to a function

  • resolver_error_handler (callable | None) – If given, a callable that generates an Operation used for handling ResolveErrors

  • pythonic_params (bool) – When True CamelCase parameters are converted to snake_case and an underscore is appended to any shadowed built-ins

  • options (dict | None) – New style options dictionary.

  • pass_context_arg_name (str | None) – If not None URL request handling functions with an argument matching this name will be passed the framework’s request context.

static make_security_handler_factory(pass_context_arg_name)

Create default SecurityHandlerFactory to create all security check handlers

static normalize_string(string)
add_openapi_json(self)

Adds openapi json to {base_path}/openapi.json (or {base_path}/swagger.json for swagger2)

add_openapi_yaml(self)

Adds openapi json to {base_path}/openapi.json (or {base_path}/swagger.json for swagger2)

add_swagger_ui(self)

Adds swagger ui to {base_path}/ui/

add_auth_on_not_found(self, security, security_definitions)

Adds a 404 error handler to authenticate and only expose the 404 status if the security validation pass.

async classmethod get_request(cls, req)

Convert aiohttp request to connexion

Parameters:

req – instance of aiohttp.web.Request

Returns:

connexion request instance

Return type:

ConnexionRequest

async classmethod get_response(cls, response, mimetype=None, request=None)

Get response. This method is used in the lifecycle decorators

Return type:

aiohttp.web.Response

add_operation(self, path, method)

Adds one operation to the api.

This method uses the OperationID identify the module and function that will handle the operation

From Swagger Specification:

OperationID

A friendly name for the operation. The id MUST be unique among all operations described in the API. Tools and libraries MAY use the operation id to uniquely identify an operation.

add_paths(self, paths=None)

Adds the paths defined in the specification as endpoints

classmethod get_connexion_response(cls, response, mimetype=None)

Cast framework dependent response to ConnexionResponse used for schema validation

json_loads(self, data)