更新环境配置以控制文档启用状态
This commit is contained in:
@@ -6,6 +6,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
|
|||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
PROJECT_NAME: str = "TJWater Server"
|
PROJECT_NAME: str = "TJWater Server"
|
||||||
|
ENVIRONMENT: str = "local"
|
||||||
API_V1_STR: str = "/api/v1"
|
API_V1_STR: str = "/api/v1"
|
||||||
|
|
||||||
# JWT 配置
|
# JWT 配置
|
||||||
|
|||||||
+6
-2
@@ -53,13 +53,17 @@ async def lifespan(app: FastAPI):
|
|||||||
logger.info("Database connections closed")
|
logger.info("Database connections closed")
|
||||||
|
|
||||||
|
|
||||||
|
# 根据环境配置决定是否启用文档
|
||||||
|
is_production = settings.ENVIRONMENT.lower() == "production"
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
title=settings.PROJECT_NAME,
|
title=settings.PROJECT_NAME,
|
||||||
description="TJWater Server - 供水管网智能管理系统",
|
description="TJWater Server - 供水管网智能管理系统",
|
||||||
version="1.0.0",
|
version="1.0.0",
|
||||||
docs_url="/docs",
|
docs_url=None if is_production else "/docs",
|
||||||
redoc_url="/redoc",
|
redoc_url=None if is_production else "/redoc",
|
||||||
|
openapi_url=None if is_production else "/openapi.json",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user