Skip to content

Commit

Permalink
Remove /redoc and add further configuration to /docs
Browse files Browse the repository at this point in the history
Remove `/redoc` by setting `redoc_url` to `None`, and move `/docs` to a custom endpoint which returns the swagger UI with some custom configuration.
  • Loading branch information
b-rowan committed Aug 23, 2024
1 parent 3b4fde3 commit 4ff1716
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion goosebit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Annotated

from fastapi import Depends, FastAPI
from fastapi.openapi.docs import get_swagger_ui_html
from fastapi.requests import Request
from fastapi.responses import RedirectResponse
from fastapi.security import OAuth2PasswordRequestForm
Expand Down Expand Up @@ -33,7 +34,8 @@ async def lifespan(_: FastAPI):
"name": "Apache 2.0",
"identifier": "Apache-2.0",
},
swagger_ui_parameters={"operationsSorter": "alpha"},
redoc_url=None,
docs_url=None,
openapi_tags=[
{
"name": "login",
Expand Down Expand Up @@ -82,3 +84,13 @@ async def logout(request: Request):
resp = RedirectResponse(request.url_for("login_get"), status_code=302)
resp.delete_cookie(key="session_id")
return resp


@app.get("/docs")
async def swagger_docs(request: Request):
return get_swagger_ui_html(
title="gooseBit docs",
openapi_url="/openapi.json",
swagger_favicon_url=str(request.url_for("static", path="/favicon.svg")),
swagger_ui_parameters={"operationsSorter": "alpha"},
)

0 comments on commit 4ff1716

Please sign in to comment.