Skip to content

Commit

Permalink
Prevent risk of // in OpenAPI URL
Browse files Browse the repository at this point in the history
* `ROOT_PATH` defaults to `/`
* Left Strip `/` from `app.openapi_url` to prevent `//openapi.json`
  • Loading branch information
rblaine95 committed Sep 27, 2024
1 parent 7cae373 commit 800996b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ def create_app() -> FastAPI:
# Use Scalar instead of Swagger
@app.get("/docs", include_in_schema=False)
async def scalar_html():
openapi_url = os.path.join(ROOT_PATH, app.openapi_url.lstrip("/"))
return get_scalar_api_reference(
openapi_url=ROOT_PATH + app.openapi_url,
openapi_url=openapi_url,
title=app.title,
)

Expand Down

0 comments on commit 800996b

Please sign in to comment.