Add Message schema
This commit is contained in:
parent
7d1d99170e
commit
4996b5ff22
38
schemas/message.py
Normal file
38
schemas/message.py
Normal file
@ -0,0 +1,38 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
from uuid import UUID
|
||||
|
||||
|
||||
class MessageBase(BaseModel):
|
||||
sender_id: UUID = Field(..., description="ID of the message sender")
|
||||
recipient_id: UUID = Field(..., description="ID of the message recipient")
|
||||
content: str = Field(..., min_length=1, description="Content of the message")
|
||||
is_read: bool = Field(default=False, description="Message read status")
|
||||
|
||||
|
||||
class MessageCreate(MessageBase):
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"sender_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"recipient_id": "123e4567-e89b-12d3-a456-426614174001",
|
||||
"content": "Hello, how are you?",
|
||||
"is_read": False
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Message(MessageBase):
|
||||
id: UUID
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"id": "123e4567-e89b-12d3-a456-426614174002",
|
||||
"sender_id": "123e4567-e89b-12d3-a456-426614174000",
|
||||
"recipient_id": "123e4567-e89b-12d3-a456-426614174001",
|
||||
"content": "Hello, how are you?",
|
||||
"is_read": False
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user