更新环境配置以控制文档启用状态
This commit is contained in:
@@ -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
@@ -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",
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user