cal-core 0.2.158

Callable core lib
Documentation
// File: cal-core/src/rest/error.rs

use serde::{Deserialize, Serialize};
#[cfg(feature = "openapi")]
use utoipa::ToSchema;

/// Generic error response
#[derive(Debug, Serialize, Deserialize)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
#[cfg_attr(feature = "openapi", schema(
    title ="Generic error response for API endpoints",
    example = json!({
        "error": "Resource not found",
        "details": {
            "resource_type": "contact",
            "resource_id": "507f1f77bcf86cd799439011"
        }
    })
))]
pub struct ErrorResponse {
    /// Error message
    #[cfg_attr(feature = "openapi", schema(example = "Resource not found"))]
    pub error: String,

    /// Additional error details
    #[cfg_attr(feature = "openapi", schema(example = json!({"field": "email", "reason": "already_exists"})))]
    pub details: Option<serde_json::Value>,
}