Skip to content

Commit

Permalink
Implement MultipartField for objects
Browse files Browse the repository at this point in the history
  • Loading branch information
vigoo committed Sep 18, 2024
1 parent 5ae9bb7 commit a2f517a
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/rust/model_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit a2f517a

Please sign in to comment.