From 3509a64bff0d7da37505be1bdfa922fe1ee1b8fe Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 13:19:15 +0000 Subject: [PATCH] Add Person schema --- schemas/person.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 schemas/person.py diff --git a/schemas/person.py b/schemas/person.py new file mode 100644 index 0000000..588a5fa --- /dev/null +++ b/schemas/person.py @@ -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" + } + } \ No newline at end of file