connexion.middleware.response_validation

Validation Middleware.

Module Contents

Classes

ResponseValidationOperation

ResponseValidationAPI

Validation API.

ResponseValidationMiddleware

Middleware for validating requests according to the API contract.

Attributes

logger

connexion.middleware.response_validation.logger
class connexion.middleware.response_validation.ResponseValidationOperation(next_app: starlette.types.ASGIApp, *, operation: connexion.operations.AbstractOperation, validator_map: Optional[dict] = None)
extract_content_type(self, headers: List[Tuple[bytes, bytes]]) Tuple[str, str]

Extract the mime type and encoding from the content type headers.

Parameters:

headers – Headers from ASGI scope

Returns:

A tuple of mime type, encoding

validate_mime_type(self, mime_type: str) None

Validate the mime type against the spec.

Parameters:

mime_type – mime type from content type header

static validate_required_headers(headers: List[tuple], response_definition: dict) None
async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send)
class connexion.middleware.response_validation.ResponseValidationAPI(*args, validator_map=None, validate_responses=False, **kwargs)

Bases: connexion.middleware.abstract.RoutedAPI[ResponseValidationOperation]

Validation API.

jsonifier
__slots__ = []
make_operation(self, operation: connexion.operations.AbstractOperation) ResponseValidationOperation

Create an operation of the operation_cls type.

add_paths(self) None
add_operation(self, path: str, method: str) None
classmethod __class_getitem__(cls, params)
classmethod __init_subclass__(cls, *args, **kwargs)
class connexion.middleware.response_validation.ResponseValidationMiddleware(app: starlette.types.ASGIApp)

Bases: connexion.middleware.abstract.RoutedMiddleware[ResponseValidationAPI]

Middleware for validating requests according to the API contract.

api_cls
__slots__ = []
add_api(self, specification: Union[pathlib.Path, str, dict], **kwargs) API

Register an API represented by a single OpenAPI specification on this middleware. Multiple APIs can be registered on a single middleware.

async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send) None

Fetches the operation related to the request and calls it.

classmethod __class_getitem__(cls, params)
classmethod __init_subclass__(cls, *args, **kwargs)