Add Hotel schema
This commit is contained in:
parent
49bb870948
commit
fc76c60e4a
48
schemas/hotel.py
Normal file
48
schemas/hotel.py
Normal file
@ -0,0 +1,48 @@
|
||||
from pydantic import BaseModel, Field, EmailStr, HttpUrl
|
||||
from typing import Optional, List
|
||||
from decimal import Decimal
|
||||
|
||||
class HotelBase(BaseModel):
|
||||
name: str = Field(..., min_length=2, max_length=100, description="Hotel name")
|
||||
description: Optional[str] = Field(None, description="Hotel description")
|
||||
location: str = Field(..., min_length=2, max_length=100, description="Hotel location")
|
||||
address: str = Field(..., min_length=5, max_length=200, description="Hotel address")
|
||||
rating: float = Field(..., ge=0, le=5, description="Hotel rating")
|
||||
price_per_night: float = Field(..., gt=0, description="Price per night")
|
||||
amenities: Optional[str] = Field(None, description="Hotel amenities")
|
||||
images: Optional[str] = Field(None, description="Hotel images")
|
||||
contact_number: Optional[str] = Field(None, max_length=20, description="Contact number")
|
||||
email: Optional[EmailStr] = Field(None, description="Hotel email")
|
||||
website: Optional[HttpUrl] = Field(None, description="Hotel website")
|
||||
total_rooms: Optional[int] = Field(None, gt=0, description="Total number of rooms")
|
||||
is_active: bool = Field(default=True, description="Hotel active status")
|
||||
latitude: Optional[float] = Field(None, ge=-90, le=90, description="Hotel latitude")
|
||||
longitude: Optional[float] = Field(None, ge=-180, le=180, description="Hotel longitude")
|
||||
|
||||
class HotelCreate(HotelBase):
|
||||
class Config:
|
||||
schema_extra = {
|
||||
"example": {
|
||||
"name": "Grand Hotel",
|
||||
"description": "Luxury hotel in the heart of the city",
|
||||
"location": "New York",
|
||||
"address": "123 Main Street, New York, NY 10001",
|
||||
"rating": 4.5,
|
||||
"price_per_night": 299.99,
|
||||
"amenities": "WiFi, Pool, Spa, Restaurant",
|
||||
"images": "hotel1.jpg,hotel2.jpg",
|
||||
"contact_number": "+1-123-456-7890",
|
||||
"email": "info@grandhotel.com",
|
||||
"website": "https://www.grandhotel.com",
|
||||
"total_rooms": 200,
|
||||
"is_active": True,
|
||||
"latitude": 40.7128,
|
||||
"longitude": -74.0060
|
||||
}
|
||||
}
|
||||
|
||||
class HotelResponse(HotelBase):
|
||||
id: int = Field(..., description="Hotel ID")
|
||||
|
||||
class Config:
|
||||
orm_mode = True
|
Loading…
x
Reference in New Issue
Block a user