Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/titiler/core/titiler/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,15 @@ def update_openapi(app: FastAPI) -> FastAPI:
SOFTWARE.
"""
# Find the route for the openapi_url in the app
openapi_route: Route = next(
route for route in app.router.routes if route.path == app.openapi_url
)
openapi_route: Route | None = None
for route in app.router.routes:
if route.path == app.openapi_url:
openapi_route = route
break

if openapi_route is None:
raise StopIteration()

# Store the old endpoint function so we can call it from the patched function
old_endpoint = openapi_route.endpoint

Expand All @@ -335,7 +341,6 @@ async def patched_openapi_endpoint(req: Request) -> Response:
# our patched function and replace the existing app with it.
openapi_route.app = request_response(patched_openapi_endpoint)

# return the patched app
return app


Expand Down