hulai-website/hulai-admin-api/app/schemas/destination_detail.py

36 行
873 B
Python

from __future__ import annotations
from pydantic import BaseModel, field_validator
class DestinationDetailSchema(BaseModel):
name: str
slug: str
subtitle: str | None = None
cover_image: str | None = None
description: str | None = None
location: str | None = None
best_season: str | None = None
duration: str | None = None
highlights: list = []
gallery: list = []
tags: list = []
is_visible: bool = True
@field_validator('highlights', 'gallery', 'tags', mode='before')
@classmethod
def coerce_none_to_list(cls, v):
return v if v is not None else []
class DestinationDetailResponse(DestinationDetailSchema):
id: int
sort_order: int = 0
class Config:
from_attributes = True
class DestinationDetailListResponse(BaseModel):
items: list[DestinationDetailResponse]
total: int