From c80b21d47e523bfec357ef0213bd658c33bd41d1 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Thu, 27 Mar 2025 10:29:16 +0000 Subject: [PATCH] Add Flower schema --- schemas/flower.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 schemas/flower.py diff --git a/schemas/flower.py b/schemas/flower.py new file mode 100644 index 0000000..6093c81 --- /dev/null +++ b/schemas/flower.py @@ -0,0 +1,41 @@ +from pydantic import BaseModel, Field +from typing import Optional +from datetime import datetime +from uuid import UUID + +class FlowerBase(BaseModel): + name: str = Field(..., index=True, min_length=1, max_length=100) + scientific_name: Optional[str] = Field(None, max_length=150) + description: Optional[str] = None + color: Optional[str] = Field(None, max_length=50) + bloom_season: Optional[str] = Field(None, max_length=50) + height: Optional[int] = Field(None, ge=0) + sunlight_needs: Optional[str] = Field(None, max_length=50) + water_needs: Optional[str] = Field(None, max_length=50) + is_perennial: bool = True + hardiness_zone: Optional[str] = Field(None, max_length=50) + +class FlowerCreate(FlowerBase): + class Config: + schema_extra = { + "example": { + "name": "Rose", + "scientific_name": "Rosa", + "description": "A woody perennial flowering plant", + "color": "Red", + "bloom_season": "Summer", + "height": 100, + "sunlight_needs": "Full sun", + "water_needs": "Moderate", + "is_perennial": True, + "hardiness_zone": "6-9" + } + } + +class Flower(FlowerBase): + id: UUID + created_at: datetime + updated_at: datetime + + class Config: + orm_mode = True \ No newline at end of file