Skip to main content

distri_a2a/
lib.rs

1mod a2a_types;
2pub use a2a_types::*;
3
4#[cfg(test)]
5mod tests {
6    use crate::AgentCard;
7    use schemars::schema_for;
8    use serde_json;
9    use std::fs;
10
11    #[test]
12    fn validate_agent_card_schema() {
13        let schema = schema_for!(AgentCard);
14        let schema_json = serde_json::to_string_pretty(&schema).unwrap();
15
16        // Optional: save the generated schema to a file for inspection
17        // fs::write("schema.json", &schema_json).unwrap();
18
19        let spec_schema_str = fs::read_to_string("a2a.json").unwrap();
20        let spec_schema: serde_json::Value = serde_json::from_str(&spec_schema_str).unwrap();
21
22        let generated_schema: serde_json::Value = serde_json::from_str(&schema_json).unwrap();
23
24        assert_eq!(
25            generated_schema["definitions"]["AgentCard"],
26            spec_schema["components"]["schemas"]["AgentCard"]
27        );
28    }
29}