use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct PutMatch3DWorkRequest { pub game_name: String, #[serde(default)] pub theme_text: Option, pub summary: String, pub tags: Vec, #[serde(default)] pub cover_image_src: Option, #[serde(default)] pub reference_image_src: Option, pub clear_count: u32, pub difficulty: u32, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Match3DWorkSummaryResponse { pub work_id: String, pub profile_id: String, pub owner_user_id: String, #[serde(default)] pub source_session_id: Option, pub game_name: String, pub theme_text: String, pub summary: String, pub tags: Vec, #[serde(default)] pub cover_image_src: Option, #[serde(default)] pub reference_image_src: Option, pub clear_count: u32, pub difficulty: u32, pub publication_status: String, pub play_count: u32, pub updated_at: String, #[serde(default)] pub published_at: Option, pub publish_ready: bool, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Match3DWorkProfileResponse { #[serde(flatten)] pub summary: Match3DWorkSummaryResponse, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Match3DWorksResponse { pub items: Vec, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Match3DWorkDetailResponse { pub item: Match3DWorkProfileResponse, } #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct Match3DWorkMutationResponse { pub item: Match3DWorkProfileResponse, } #[cfg(test)] mod tests { use super::*; use serde_json::json; #[test] fn match3d_work_request_uses_camel_case() { let payload = serde_json::to_value(PutMatch3DWorkRequest { game_name: "水果抓大鹅".to_string(), theme_text: Some("水果".to_string()), summary: "水果主题".to_string(), tags: vec!["水果".to_string()], cover_image_src: None, reference_image_src: None, clear_count: 4, difficulty: 5, }) .expect("payload should serialize"); assert_eq!(payload["gameName"], json!("水果抓大鹅")); assert_eq!(payload["clearCount"], json!(4)); } }