From 5651e53392161f89caab9f767ec39ecb62977bae Mon Sep 17 00:00:00 2001 From: Alessio Renda Date: Tue, 27 Feb 2024 12:53:01 +0100 Subject: [PATCH] [FIX] fastapi: update loading of middlewares --- fastapi/models/fastapi_endpoint.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastapi/models/fastapi_endpoint.py b/fastapi/models/fastapi_endpoint.py index ed255b9a..3c2cf363 100644 --- a/fastapi/models/fastapi_endpoint.py +++ b/fastapi/models/fastapi_endpoint.py @@ -214,6 +214,8 @@ def _get_app(self) -> FastAPI: app = FastAPI(**self._prepare_fastapi_app_params()) for router in self._get_fastapi_routers(): app.include_router(router=router) + for middleware, options in self._get_fastapi_app_middlewares(): + app.add_middleware(middleware, **options) app.dependency_overrides[dependencies.fastapi_endpoint_id] = partial( lambda a: a, self.id ) @@ -258,7 +260,6 @@ def _prepare_fastapi_app_params(self) -> Dict[str, Any]: return { "title": self.name, "description": self.description, - "middleware": self._get_fastapi_app_middlewares(), "dependencies": self._get_fastapi_app_dependencies(), }