Skip to content

Commit

Permalink
Fix openapi.json path in Swagger UI behind NGINX
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickkwang committed Jun 8, 2021
1 parent 37114d1 commit 7224dbf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions strider/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import httpx
from redis import Redis
from starlette.middleware.cors import CORSMiddleware
from starlette.responses import HTMLResponse
import yaml

from reasoner_pydantic import Query, Message, Response as ReasonerResponse
Expand Down Expand Up @@ -308,10 +309,12 @@ async def handle_ars(


@APP.get("/docs", include_in_schema=False)
async def custom_swagger_ui_html():
async def custom_swagger_ui_html(req: Request) -> HTMLResponse:
"""Customize Swagger UI."""
root_path = req.scope.get("root_path", "").rstrip("/")
openapi_url = root_path + APP.openapi_url
return get_swagger_ui_html(
openapi_url=APP.openapi_url,
openapi_url=openapi_url,
title=APP.title + " - Swagger UI",
oauth2_redirect_url=APP.swagger_ui_oauth2_redirect_url,
swagger_favicon_url="/static/favicon.svg",
Expand Down

0 comments on commit 7224dbf

Please sign in to comment.