1
0
Fork 0

add derives to generated structs

This commit is contained in:
Cyborus 2024-01-16 18:12:56 -05:00
parent 70b4081cde
commit edf4646953
No known key found for this signature in database

View file

@ -711,6 +711,11 @@ fn create_struct_for_definition(
(true, false) => format!("Option<{prop_ty}>"),
(true, true) => format!("Option<Box<{prop_ty}>>"),
};
if &field_name != prop_name {
fields.push_str("#[serde(rename = \"");
fields.push_str(prop_name);
fields.push_str("\")]\n");
}
fields.push_str(&field_name);
fields.push_str(": ");
fields.push_str(&field_ty);
@ -718,7 +723,7 @@ fn create_struct_for_definition(
}
}
let out = format!("{docs}pub struct {name} {{\n{fields}}}\n\n");
let out = format!("{docs}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]\npub struct {name} {{\n{fields}}}\n\n");
Ok(out)
}