Add ServerTime schema

This commit is contained in:
Backend IM Bot 2025-03-26 16:12:51 +00:00
parent f79e29368b
commit c18352ccdf

29
schemas/servertime.py Normal file
View File

@ -0,0 +1,29 @@
from pydantic import BaseModel, Field
from datetime import datetime
from typing import Optional
class ServerTimeBase(BaseModel):
timezone: str = Field(default="UTC", description="Timezone for the server")
class ServerTimeCreate(ServerTimeBase):
current_time: Optional[datetime] = Field(default_factory=datetime.now, description="Current server time")
class Config:
schema_extra = {
"example": {
"current_time": "2024-01-01T12:00:00",
"timezone": "UTC"
}
}
class ServerTime(ServerTimeBase):
current_time: datetime = Field(..., description="Current server time")
class Config:
orm_mode = True
schema_extra = {
"example": {
"current_time": "2024-01-01T12:00:00",
"timezone": "UTC"
}
}