Skip to content

Commit

Permalink
Add description to fastapi app
Browse files Browse the repository at this point in the history
  • Loading branch information
koldakov committed Sep 4, 2024
1 parent 1eece5a commit 3286d1c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions futuramaapi/apps/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
from futuramaapi.middlewares.cors import CORSMiddleware
from futuramaapi.middlewares.secure import HTTPSRedirectMiddleware
from futuramaapi.repositories.session import session_manager
from futuramaapi.utils._compat import metadata

if TYPE_CHECKING:
from pydantic import HttpUrl
from starlette.routing import Route, WebSocketRoute

mimetypes.add_type("image/webp", ".webp")
Expand Down Expand Up @@ -51,6 +53,12 @@ def _init_sentry() -> None:
profiles_sample_rate=settings.sentry.profiles_sample_rate,
)

@property
def description(self):
summary: str = metadata["summary"]
project_url: HttpUrl = settings.build_url(is_static=False)
return f"{summary} [Go back home]({project_url})."

@abstractmethod
def get_app(
self,
Expand All @@ -73,6 +81,7 @@ def get_app(
redoc_url=None,
lifespan=lifespan,
version=self.version,
description=self.description,
)

def _add_middlewares(self) -> None:
Expand Down

0 comments on commit 3286d1c

Please sign in to comment.