""" Repository Pydantic schemas. """ from typing import Optional from pydantic import BaseModel, Field class CommitInfo(BaseModel): """ Schema for commit information. """ hash: str = Field(description="Commit hash") author: str = Field(description="Commit author") message: str = Field(description="Commit message") timestamp: int = Field(description="Commit timestamp (Unix timestamp)") model_config = { "json_schema_extra": { "examples": [ { "hash": "a1b2c3d4e5f6...", "author": "John Doe ", "message": "Add new feature", "timestamp": 1711891200 } ] } } class RepoResponse(BaseModel): """ Schema for repository response. """ id: int = Field(description="Repository ID") server_id: int = Field(description="Server ID") name: str = Field(description="Repository name") full_name: str = Field(description="Repository full name (e.g., 'owner/repo')") clone_url: str = Field(description="Git clone URL") local_path: str = Field(description="Local storage path") last_sync_at: Optional[int] = Field( default=None, description="Last sync timestamp (Unix timestamp)" ) status: str = Field(description="Repository status") created_at: int = Field(description="Creation timestamp (Unix timestamp)") model_config = { "json_schema_extra": { "examples": [ { "id": 1, "server_id": 1, "name": "my-repo", "full_name": "myorg/my-repo", "clone_url": "https://gitea.example.com/myorg/my-repo.git", "local_path": "/data/gitea-mirror/myorg/my-repo", "last_sync_at": 1711891200, "status": "success", "created_at": 1711804800 } ] } }