diff --git a/api/advent22_api/core/settings.py b/api/advent22_api/core/settings.py index 65737f4..92392c4 100644 --- a/api/advent22_api/core/settings.py +++ b/api/advent22_api/core/settings.py @@ -1,6 +1,10 @@ +from typing import TypeVar + from pydantic import BaseModel from pydantic_settings import BaseSettings, SettingsConfigDict +T = TypeVar("T") + class DavSettings(BaseModel): """ @@ -49,9 +53,23 @@ class Settings(BaseSettings): # openapi settings ##### - openapi_url: str = "/openapi.json" - docs_url: str | None = None if production_mode else "/docs" - redoc_url: str | None = None if production_mode else "/redoc" + def __dev_value(self, value: T) -> T | None: + if self.production_mode: + return None + + return value + + @property + def openapi_url(self) -> str | None: + return self.__dev_value("/api/openapi.json") + + @property + def docs_url(self) -> str | None: + return self.__dev_value("/api/docs") + + @property + def redoc_url(self) -> str | None: + return self.__dev_value("/api/redoc") ##### # webdav settings