Skip to content

Commit 600c224

Browse files
committed
fix: only customize swagger UI if we have init oauth
1 parent 8e16916 commit 600c224

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/stac_auth_proxy/app.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)