Files
python_parser/python_parser/app/schemas/upload.py
2025-08-26 23:33:29 +03:00

45 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"
}
}
}