diff --git a/emgauwa-core/src/handlers/v1/schedules.rs b/emgauwa-core/src/handlers/v1/schedules.rs index bd521aa..cb58d92 100644 --- a/emgauwa-core/src/handlers/v1/schedules.rs +++ b/emgauwa-core/src/handlers/v1/schedules.rs @@ -13,6 +13,7 @@ use crate::handlers::errors::ApiError; pub struct RequestSchedule { name: String, periods: DbPeriods, + #[serde(default)] // empty tags are allowed tags: Vec, } @@ -60,7 +61,7 @@ pub async fn show( .await? .ok_or(DatabaseError::NotFound)?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule)?; Ok(HttpResponse::Ok().json(return_schedule)) } @@ -77,7 +78,7 @@ pub async fn add( .set_tags(&mut pool_conn, data.tags.as_slice()) .await?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, new_schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, new_schedule)?; Ok(HttpResponse::Created().json(return_schedule)) } @@ -135,7 +136,7 @@ pub async fn update( .set_tags(&mut pool_conn, data.tags.as_slice()) .await?; - let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule); + let return_schedule = Schedule::from_db_model(&mut pool_conn, schedule)?; Ok(HttpResponse::Ok().json(return_schedule)) }