Add ServerTime schema
This commit is contained in:
parent
f79e29368b
commit
c18352ccdf
29
schemas/servertime.py
Normal file
29
schemas/servertime.py
Normal 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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user