Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Clone trait to all structs #23

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading