更新环境配置以控制文档启用状态

This commit is contained in:
2026-03-11 17:57:47 +08:00
parent 72d642fcf6
commit baf899eaeb
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -6,6 +6,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
PROJECT_NAME: str = "TJWater Server"
ENVIRONMENT: str = "local"
API_V1_STR: str = "/api/v1"
# JWT 配置
+6 -2
View File
@@ -53,13 +53,17 @@ async def lifespan(app: FastAPI):
logger.info("Database connections closed")
# 根据环境配置决定是否启用文档
is_production = settings.ENVIRONMENT.lower() == "production"
app = FastAPI(
lifespan=lifespan,
title=settings.PROJECT_NAME,
description="TJWater Server - 供水管网智能管理系统",
version="1.0.0",
docs_url="/docs",
redoc_url="/redoc",
docs_url=None if is_production else "/docs",
redoc_url=None if is_production else "/redoc",
openapi_url=None if is_production else "/openapi.json",
)