From 39d1972c6710aecce4b010cff3685ece50b339f6 Mon Sep 17 00:00:00 2001 From: Samarpan Harit Date: Tue, 17 Dec 2024 23:10:34 +0530 Subject: [PATCH] Add api error response --- todo/dto/responses/error_response.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 todo/dto/responses/error_response.py diff --git a/todo/dto/responses/error_response.py b/todo/dto/responses/error_response.py new file mode 100644 index 0000000..4126b98 --- /dev/null +++ b/todo/dto/responses/error_response.py @@ -0,0 +1,21 @@ +from enum import Enum +from typing import Dict, List +from pydantic import BaseModel + + +class ApiErrorSource(Enum): + PARAMETER = "parameter" + POINTER = "pointer" + HEADER = "header" + + +class ApiErrorDetail(BaseModel): + source: Dict[ApiErrorSource, str] | None = None + title: str | None = None + detail: str | None = None + + +class ApiErrorResponse(BaseModel): + statusCode: int + message: str + errors: List[ApiErrorDetail]