mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
hide openapi, docs and redoc in production mode
This commit is contained in:
parent
9063ebe93a
commit
e83f56a932
1 changed files with 21 additions and 3 deletions
|
@ -1,6 +1,10 @@
|
||||||
|
from typing import TypeVar
|
||||||
|
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||||
|
|
||||||
|
T = TypeVar("T")
|
||||||
|
|
||||||
|
|
||||||
class DavSettings(BaseModel):
|
class DavSettings(BaseModel):
|
||||||
"""
|
"""
|
||||||
|
@ -49,9 +53,23 @@ class Settings(BaseSettings):
|
||||||
# openapi settings
|
# openapi settings
|
||||||
#####
|
#####
|
||||||
|
|
||||||
openapi_url: str = "/openapi.json"
|
def __dev_value(self, value: T) -> T | None:
|
||||||
docs_url: str | None = None if production_mode else "/docs"
|
if self.production_mode:
|
||||||
redoc_url: str | None = None if production_mode else "/redoc"
|
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
|
# webdav settings
|
||||||
|
|
Loading…
Reference in a new issue