connexion.middleware.routing

Module Contents

Classes

RoutingOperation

RoutingAPI

API implementation on top of Starlette Router for Connexion middleware.

RoutingMiddleware

Middlewares that need the APIs to be registered on them should inherit from this base

class connexion.middleware.routing.RoutingOperation(operation_id: Optional[str], next_app: starlette.types.ASGIApp)
classmethod from_operation(cls, operation: connexion.operations.AbstractOperation, next_app: starlette.types.ASGIApp)
async __call__(self, scope: starlette.types.Scope, receive: starlette.types.Receive, send: starlette.types.Send) None

Attach operation to scope and pass it to the next app

class connexion.middleware.routing.RoutingAPI(specification: Union[pathlib.Path, str, dict], *, next_app: starlette.types.ASGIApp, base_path: Optional[str] = None, arguments: Optional[dict] = None, resolver: Optional[connexion.resolver.Resolver] = None, resolver_error_handler: Optional[Callable] = None, debug: bool = False, **kwargs)

Bases: connexion.apis.AbstractRoutingAPI

API implementation on top of Starlette Router for Connexion middleware.

add_operation(self, path: str, method: str) None
add_paths(self, paths: Optional[dict] = None) None

Adds the paths defined in the specification as endpoints

class connexion.middleware.routing.RoutingMiddleware(app: starlette.types.ASGIApp)

Bases: connexion.middleware.abstract.AppMiddleware

Middlewares that need the APIs to be registered on them should inherit from this base class

Middleware that resolves the Operation for an incoming request and attaches it to the scope.

Parameters:

app – app to wrap in middleware.

__slots__ = []
add_api(self, specification: Union[pathlib.Path, str, dict], base_path: Optional[str] = None, arguments: Optional[dict] = None, **kwargs) None

Add an API to the router based on a OpenAPI spec.

Parameters:
  • specification – OpenAPI spec as dict or path to file.

  • base_path – Base path where to add this API.

  • arguments – Jinja arguments to replace in the spec.

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

Route request to matching operation, and attach it to the scope before calling the next app.