refactor: extract Pydantic schemas into schemas/ subpackages
Extract inline Pydantic models from 9 API routers into dedicated schema modules under schemas/: - schemas/tool/tool_type.py — ToolTypeCreate, ToolTypeUpdate, etc. - schemas/tool/tool_instance.py — CreateInstanceRequest, StartInstanceRequest - schemas/config/config_profile.py — ConfigProfileCreate, ConfigProfileUpdate, ConfigProfileResponse, DefaultProfilesUpdate, ValidateGitUrlRequest, etc. - schemas/system/health.py — DatabaseHealth, DiskHealth, HealthResponse, etc. - schemas/user/user.py — UserProfileResponse, UserProfileUpdate - schemas/user/user_config.py — UserConfigResponse, UserConfigUpdate - schemas/project/project.py — ProjectCreate, ProjectUpdate, etc. - schemas/project/ssh_key.py — SSHKeyCreate, SSHKeyResponse, etc. - schemas/project/git_repository.py — GitRepositoryCreate, etc. API routers now import from src.schemas.* instead of defining inline. Net change: -548 lines across 16 files. Quality gates: py_compile passed, ruff passed on all 18 files.
This commit is contained in:
@@ -1 +1,27 @@
|
||||
"""Config module."""
|
||||
"""Config schemas module."""
|
||||
|
||||
from src.schemas.config.config_profile import (
|
||||
ConfigProfileCreate,
|
||||
ConfigProfileIncludeUpdate,
|
||||
ConfigProfileResponse,
|
||||
ConfigProfileUpdate,
|
||||
DefaultProfilesUpdate,
|
||||
GitMountItem,
|
||||
GitMountMapping,
|
||||
MountItem,
|
||||
ValidateGitUrlRequest,
|
||||
ValidateGitUrlResponse,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"ConfigProfileCreate",
|
||||
"ConfigProfileIncludeUpdate",
|
||||
"ConfigProfileResponse",
|
||||
"ConfigProfileUpdate",
|
||||
"DefaultProfilesUpdate",
|
||||
"GitMountItem",
|
||||
"GitMountMapping",
|
||||
"MountItem",
|
||||
"ValidateGitUrlRequest",
|
||||
"ValidateGitUrlResponse",
|
||||
]
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"""Config profile request/response schemas."""
|
||||
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
from pydantic import BaseModel, Field, field_validator, model_validator
|
||||
|
||||
@@ -13,8 +12,8 @@ def _validate_uuid(v: str | None) -> str | None:
|
||||
return v
|
||||
try:
|
||||
uuid.UUID(v)
|
||||
except ValueError:
|
||||
raise ValueError(f"Invalid UUID: {v}")
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Invalid UUID: {v}") from exc
|
||||
return v
|
||||
|
||||
|
||||
@@ -236,8 +235,8 @@ class ConfigProfileIncludeUpdate(BaseModel):
|
||||
for item in v:
|
||||
try:
|
||||
uuid.UUID(item)
|
||||
except ValueError:
|
||||
raise ValueError(f"Invalid UUID in includes: {item}")
|
||||
except ValueError as exc:
|
||||
raise ValueError(f"Invalid UUID in includes: {item}") from exc
|
||||
return v
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user