45 lines
1.6 KiB
Python
45 lines
1.6 KiB
Python
from pydantic import BaseModel, Field
|
||
from typing import Optional, Dict, Any
|
||
from enum import Enum
|
||
|
||
|
||
class UploadStatus(str, Enum):
|
||
SUCCESS = "success"
|
||
PROCESSING = "processing"
|
||
ERROR = "error"
|
||
|
||
|
||
class UploadResponse(BaseModel):
|
||
success: bool = Field(..., description="Успешность операции")
|
||
message: str = Field(..., description="Сообщение о результате операции")
|
||
object_id: Optional[str] = Field(None, description="Идентификатор загруженного объекта")
|
||
|
||
class Config:
|
||
json_schema_extra = {
|
||
"example": {
|
||
"success": True,
|
||
"message": "Файл успешно загружен и обработан",
|
||
"object_id": "65a1b2c3d4e5f6a7b8c9d0e1",
|
||
}
|
||
}
|
||
|
||
|
||
class UploadErrorResponse(BaseModel):
|
||
success: bool = Field(False, description="Успешность операции")
|
||
message: str = Field(..., description="Сообщение об ошибке")
|
||
error_code: Optional[str] = Field(None, description="Код ошибки")
|
||
details: Optional[Dict[str, Any]] = Field(None, description="Детали ошибки")
|
||
|
||
class Config:
|
||
json_schema_extra = {
|
||
"example": {
|
||
"success": False,
|
||
"message": "Неверный формат файла",
|
||
"error_code": "INVALID_FILE_FORMAT",
|
||
"details": {
|
||
"expected_formats": [".zip"],
|
||
"received_format": ".rar"
|
||
}
|
||
}
|
||
}
|