use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SkillObject {
pub id: String,
pub name: String,
pub description: String,
pub created_at: i64,
#[serde(rename = "type")]
pub skill_type: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct SkillRef {
pub skill_id: String,
}
impl SkillRef {
pub fn new(skill_id: impl Into<String>) -> Self {
Self { skill_id: skill_id.into() }
}
}
#[cfg(test)]
mod tests {
use super::*;
use serde_json::json;
#[test]
fn skill_object_roundtrip() {
let obj = SkillObject {
id: "skill-abc".to_string(),
name: "Code Review".to_string(),
description: "Reviews code for quality".to_string(),
created_at: 1700000000,
skill_type: "custom".to_string(),
};
let json = serde_json::to_value(&obj).unwrap();
let deserialized: SkillObject = serde_json::from_value(json).unwrap();
assert_eq!(obj, deserialized);
}
#[test]
fn skill_ref_serialization() {
let skill_ref = SkillRef::new("skill-123");
let json = serde_json::to_value(&skill_ref).unwrap();
assert_eq!(json, json!({"skill_id": "skill-123"}));
}
}