reinhardt_rest/metadata/
response.rs1use super::fields::FieldInfo;
4use serde::{Deserialize, Serialize};
5use std::collections::HashMap;
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ActionMetadata {
10 pub method: String,
12 pub fields: HashMap<String, FieldInfo>,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize)]
18pub struct MetadataResponse {
19 pub name: String,
21 pub description: String,
23 #[serde(skip_serializing_if = "Option::is_none")]
25 pub renders: Option<Vec<String>>,
26 #[serde(skip_serializing_if = "Option::is_none")]
28 pub parses: Option<Vec<String>>,
29 #[serde(skip_serializing_if = "Option::is_none")]
31 pub actions: Option<HashMap<String, HashMap<String, FieldInfo>>>,
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37
38 #[test]
39 fn test_metadata_serialization() {
40 let response = MetadataResponse {
41 name: "Test View".to_string(),
42 description: "Test description".to_string(),
43 renders: Some(vec!["application/json".to_string()]),
44 parses: Some(vec!["application/json".to_string()]),
45 actions: None,
46 };
47
48 let json = serde_json::to_string(&response).unwrap();
49 assert!(json.contains("Test View"));
50 assert!(json.contains("application/json"));
51 }
52}