connexion.middleware.request_validation

Validation Middleware.

Module Contents

Classes

RequestValidationOperation

RequestValidationAPI

Validation API.

RequestValidationMiddleware

Middleware for validating requests according to the API contract.

Attributes

logger

connexion.middleware.request_validation.logger
class connexion.middleware.request_validation.RequestValidationOperation(next_app: starlette.types.ASGIApp, *, operation: connexion.operations.AbstractOperation, strict_validation: bool = False, 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

async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send)
class connexion.middleware.request_validation.RequestValidationAPI(*args, strict_validation=False, validator_map=None, uri_parser_class=None, **kwargs)

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

Validation API.

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

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.request_validation.RequestValidationMiddleware(app: starlette.types.ASGIApp)

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

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)
exception connexion.middleware.request_validation.MissingValidationOperation

Bases: Exception

Missing validation operation

Initialize self. See help(type(self)) for accurate signature.

class __cause__

exception cause

class __context__

exception context

class __suppress_context__
class __traceback__
class args
__delattr__()

Implement delattr(self, name).

__dir__()

Default dir() implementation.

__eq__()

Return self==value.

__format__()

Default object formatter.

__ge__()

Return self>=value.

__getattribute__()

Return getattr(self, name).

__gt__()

Return self>value.

__hash__()

Return hash(self).

__le__()

Return self<=value.

__lt__()

Return self<value.

__ne__()

Return self!=value.

__reduce__()

Helper for pickle.

__reduce_ex__()

Helper for pickle.

__repr__()

Return repr(self).

__setattr__()

Implement setattr(self, name, value).

__setstate__()
__sizeof__()

Size of object in memory, in bytes.

__str__()

Return str(self).

__subclasshook__()

Abstract classes can override this to customize issubclass().

This is invoked early on by abc.ABCMeta.__subclasscheck__(). It should return True, False or NotImplemented. If it returns NotImplemented, the normal algorithm is used. Otherwise, it overrides the normal algorithm (and the outcome is cached).

with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.