From c0c8f475696498e75e01f3a7f35c80133724f9a8 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Wed, 26 Mar 2025 06:54:20 -0500 Subject: [PATCH] Add Lake schema --- schemas/lake.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 schemas/lake.py diff --git a/schemas/lake.py b/schemas/lake.py new file mode 100644 index 0000000..efa8b98 --- /dev/null +++ b/schemas/lake.py @@ -0,0 +1,35 @@ +from pydantic import BaseModel, Field, validator +from typing import Optional + +class BaseLake(BaseModel): + name: str = Field(..., index=True, description="Name of the lake") + area: float = Field(..., gt=0, description="Area of the lake in square kilometers") + depth: float = Field(..., gt=0, description="Maximum depth of the lake in meters") + location: str = Field(..., description="Location or address of the lake") + + @validator('name') + def name_must_be_capitalized(cls, value): + if not value.istitle(): + raise ValueError('Lake name must be capitalized') + return value + + class Config: + schema_extra = { + "example": { + "name": "Lake Superior", + "area": 82100.0, + "depth": 406.0, + "location": "North America" + } + } + + +class LakeCreate(BaseLake): + pass + + +class LakeResponse(BaseLake): + id: int + + class Config: + orm_mode = True \ No newline at end of file