diff --git a/schemas/sealion.py b/schemas/sealion.py new file mode 100644 index 0000000..2252500 --- /dev/null +++ b/schemas/sealion.py @@ -0,0 +1,49 @@ +from pydantic import BaseModel, Field + +# Base Schema +class SeaLionBase(BaseModel): + name: str = Field(..., description="Name of the sea lion") + species: str = Field(..., description="Species of the sea lion") + age: int | None = Field(None, description="Age of the sea lion") + weight: float | None = Field(None, description="Weight of the sea lion") + location: str = Field(..., description="Location of the sea lion") + + class Config: + schema_extra = { + "example": { + "name": "Buddy", + "species": "California Sea Lion", + "age": 5, + "weight": 200.5, + "location": "Pacific Ocean" + } + } + +# Schema for Create Operation +class SeaLionCreate(SeaLionBase): + pass + +# Schema for Response +class SeaLion(SeaLionBase): + id: int = Field(..., description="Unique identifier for the sea lion") + + class Config: + schema_extra = { + "example": { + "id": 1, + "name": "Buddy", + "species": "California Sea Lion", + "age": 5, + "weight": 200.5, + "location": "Pacific Ocean" + } + } +``` + +This code defines three Pydantic models for the SeaLion entity: + +1. `SeaLionBase`: A base model that defines the common fields for the entity. +2. `SeaLionCreate`: A model that inherits from `SeaLionBase` and is used for creating new sea lion instances. +3. `SeaLion`: A model that inherits from `SeaLionBase` and includes an `id` field, which is used for representing sea lion instances in API responses. + +Each model includes field descriptions and example values in the `Config` class. The `SeaLion` model also includes an example value for the `id` field. \ No newline at end of file