Add Person schema

This commit is contained in:
Backend IM Bot 2025-03-26 13:19:15 +00:00
parent 95f107cde6
commit 3509a64bff

37
schemas/person.py Normal file
View File

@ -0,0 +1,37 @@
from pydantic import BaseModel, Field, EmailStr
from typing import Optional
class PersonBase(BaseModel):
first_name: str = Field(..., min_length=1, max_length=50)
last_name: str = Field(..., min_length=1, max_length=50)
email: EmailStr = Field(..., description="Person's email address")
phone_number: Optional[str] = Field(None, max_length=20)
address: Optional[str] = Field(None, max_length=200)
class PersonCreate(PersonBase):
class Config:
schema_extra = {
"example": {
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"phone_number": "+1234567890",
"address": "123 Main St, City, Country"
}
}
class Person(PersonBase):
id: int = Field(..., description="Person's unique identifier")
class Config:
orm_mode = True
schema_extra = {
"example": {
"id": 1,
"first_name": "John",
"last_name": "Doe",
"email": "john.doe@example.com",
"phone_number": "+1234567890",
"address": "123 Main St, City, Country"
}
}