Add Exception schema
This commit is contained in:
parent
fa5443facf
commit
f4443a83d8
@ -4,12 +4,11 @@ from datetime import datetime
|
||||
from uuid import UUID
|
||||
|
||||
class ExceptionBase(BaseModel):
|
||||
error_code: str = Field(..., max_length=50)
|
||||
error_message: str = Field(..., max_length=255)
|
||||
stack_trace: Optional[str] = Field(None)
|
||||
endpoint: str = Field(..., max_length=100)
|
||||
method: str = Field(..., max_length=10)
|
||||
request_data: Optional[str] = Field(None)
|
||||
error_code: str = Field(..., description="Error code identifier")
|
||||
error_message: str = Field(..., description="Detailed error message")
|
||||
stack_trace: Optional[str] = Field(None, description="Stack trace of the error")
|
||||
endpoint: str = Field(..., description="API endpoint where error occurred")
|
||||
request_data: Optional[str] = Field(None, description="Request data when error occurred")
|
||||
|
||||
class ExceptionCreate(ExceptionBase):
|
||||
class Config:
|
||||
@ -19,8 +18,7 @@ class ExceptionCreate(ExceptionBase):
|
||||
"error_message": "Internal Server Error",
|
||||
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
||||
"endpoint": "/api/v1/users",
|
||||
"method": "POST",
|
||||
"request_data": '{"username": "john_doe", "email": "john@example.com"}'
|
||||
"request_data": "{'user_id': '123', 'action': 'update'}"
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,8 +35,7 @@ class Exception(ExceptionBase):
|
||||
"error_message": "Internal Server Error",
|
||||
"stack_trace": "File 'app.py', line 50, in process_request\n raise Exception('Database connection failed')",
|
||||
"endpoint": "/api/v1/users",
|
||||
"method": "POST",
|
||||
"request_data": '{"username": "john_doe", "email": "john@example.com"}',
|
||||
"created_at": "2023-01-01T12:00:00"
|
||||
"request_data": "{'user_id': '123', 'action': 'update'}",
|
||||
"created_at": "2023-01-01T00:00:00"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user