Add Person schema
This commit is contained in:
parent
95f107cde6
commit
3509a64bff
37
schemas/person.py
Normal file
37
schemas/person.py
Normal 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"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user