Add Flower schema
This commit is contained in:
parent
2d90390508
commit
c80b21d47e
41
schemas/flower.py
Normal file
41
schemas/flower.py
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user