Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove /redoc and add further configuration to /docs #82

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"},
)