-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathsettings.py
43 lines (35 loc) · 1.15 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from typing import Any
from pydantic_settings import BaseSettings, SettingsConfigDict
from tools.config.fastapi import FastAPIKwArgs
class Settings(BaseSettings):
"""Environment variables settings."""
model_config = SettingsConfigDict(
env_file=(".env", ".env.local"),
env_file_encoding="utf-8",
)
IS_LOCAL: bool = False
debug: bool = False
title: str = "FastAPI"
summary: str | None = None
description: str = ""
version: str = "0.1.0"
openapi_url: str = "/openapi.json"
docs_url: str = "/docs"
redoc_url: str = "/redoc"
openapi_prefix: str = ""
api_prefix_v1: str = "/api/v1"
allowed_hosts: list[str] = ["*"]
@property
def fastapi_kwargs(self) -> dict[str, Any]:
"""FastAPI kwargs."""
return FastAPIKwArgs(
debug=self.debug,
title=self.title,
summary=self.summary,
description=self.description,
version=self.version,
openapi_url=self.openapi_url,
docs_url=self.docs_url,
redoc_url=self.redoc_url,
openapi_prefix=self.openapi_prefix,
).model_dump()