Skip to content

Commit

Permalink
Add Clone trait to all structs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
marv7000 authored Feb 26, 2024
1 parent cf7c7b3 commit eb60870
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/pathgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ fn gen_fn(name: &str, op_type: &str, op: &Operation) -> String {
let need_query = fn_query_params.len() > 0;
let fn_query_name = fn_name.to_case(Case::Pascal) + "Query";
let fn_query_struct = format!(
"#[derive(Serialize, Deserialize, Debug, Default)]\npub struct {} {{\n{}\n}}\n",
"#[derive(Serialize, Deserialize, Debug, Default, Clone)]\npub struct {} {{\n{}\n}}\n",
fn_query_name,
fn_query_params.clone().into_iter().collect::<String>()
);
Expand All @@ -131,7 +131,8 @@ fn gen_fn(name: &str, op_type: &str, op: &Operation) -> String {

// Build the response enum.
let fn_response_name = fn_name.to_case(Case::Pascal) + "Response";
result += "#[derive(Serialize, Deserialize, Debug, Default)]\n#[serde(untagged)]\npub enum ";
result +=
"#[derive(Serialize, Deserialize, Debug, Default, Clone)]\n#[serde(untagged)]\npub enum ";
result += &fn_response_name;
result += " {\n";

Expand Down
3 changes: 2 additions & 1 deletion src/structgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ pub fn gen(name: &str, schema: &Schema) -> Option<String> {
};

// Assemble struct string.
let mut result = "#[derive(Serialize, Deserialize, Debug, Default)]\npub struct ".to_owned();
let mut result =
"#[derive(Serialize, Deserialize, Debug, Default, Clone)]\npub struct ".to_owned();
result += name;
result += " {\n";

Expand Down
2 changes: 2 additions & 0 deletions src/templates/usings.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(warnings)]

use crate::util::ThanixClient;
use crate::types::*;
use serde_qs;
Expand Down

0 comments on commit eb60870

Please sign in to comment.