From a2f517a2af2459dd1578e66b208f01b7554bf306 Mon Sep 17 00:00:00 2001 From: Daniel Vigovszky Date: Wed, 18 Sep 2024 10:14:02 +0200 Subject: [PATCH] Implement MultipartField for objects --- src/rust/model_gen.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/rust/model_gen.rs b/src/rust/model_gen.rs index 28e4e6e..1d69bbe 100644 --- a/src/rust/model_gen.rs +++ b/src/rust/model_gen.rs @@ -527,7 +527,26 @@ pub fn model_gen(reference: &str, open_api: &OpenAPI, ref_cache: &mut RefCache) .reduce(|acc, e| acc + e) .unwrap_or_else(unit), ) - + line(unit() + "}"); + + line(unit() + "}") + + NewLine + + line( + unit() + + "impl " + + rust_name("crate::model", "MultipartField") + + " for " + + &name + + "{", + ) + + indented( + line(unit() + "fn to_multipart_field(&self) -> String {") + + indented(line("serde_json::to_string(self).unwrap()")) + + line("}") + + NewLine + + line(unit() + "fn mime_type(&self) -> &'static str {") + + indented(line(r#""application/json""#)) + + line("}"), + ) + + line("}"); Ok(code) }