1use serde::{Deserialize, Serialize};
4#[cfg(feature = "openapi")]
5use utoipa::ToSchema;
6
7#[derive(Debug, Serialize, Deserialize)]
9#[cfg_attr(feature = "openapi", derive(ToSchema))]
10#[cfg_attr(feature = "openapi", schema(
11 title ="Generic error response for API endpoints",
12 example = json!({
13 "error": "Resource not found",
14 "details": {
15 "resource_type": "contact",
16 "resource_id": "507f1f77bcf86cd799439011"
17 }
18 })
19))]
20pub struct ErrorResponse {
21 #[cfg_attr(feature = "openapi", schema(example = "Resource not found"))]
23 pub error: String,
24
25 #[cfg_attr(feature = "openapi", schema(example = json!({"field": "email", "reason": "already_exists"})))]
27 pub details: Option<serde_json::Value>,
28}