File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -80,14 +80,20 @@ async def lifespan(app: FastAPI):
8080 # Handlers (place catch-all proxy handler last)
8181 #
8282
83- if settings .swagger_ui_endpoint :
84- assert (
85- settings .openapi_spec_endpoint
86- ), "openapi_spec_endpoint must be set when using swagger_ui_endpoint"
83+ # If we have customized Swagger UI Init settings (e.g. a provided client_id)
84+ # then we need to serve our own Swagger UI in place of the upstream's. This requires
85+ # that we know the Swagger UI endpoint and the OpenAPI spec endpoint.
86+ if all (
87+ [
88+ settings .swagger_ui_endpoint ,
89+ settings .openapi_spec_endpoint ,
90+ settings .swagger_ui_init_oauth ,
91+ ]
92+ ):
8793 app .add_route (
8894 settings .swagger_ui_endpoint ,
8995 SwaggerUI (
90- openapi_url = settings .openapi_spec_endpoint ,
96+ openapi_url = settings .openapi_spec_endpoint , # type: ignore
9197 init_oauth = settings .swagger_ui_init_oauth ,
9298 ).route ,
9399 include_in_schema = False ,
You can’t perform that action at this time.
0 commit comments