Skip to content

Commit 7dddf1d

Browse files
authored
Merge pull request #20 from golemcloud/multipart-field-object
Implement MultipartField for objects
2 parents 5ae9bb7 + a2f517a commit 7dddf1d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/rust/model_gen.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,26 @@ pub fn model_gen(reference: &str, open_api: &OpenAPI, ref_cache: &mut RefCache)
527527
.reduce(|acc, e| acc + e)
528528
.unwrap_or_else(unit),
529529
)
530-
+ line(unit() + "}");
530+
+ line(unit() + "}")
531+
+ NewLine
532+
+ line(
533+
unit()
534+
+ "impl "
535+
+ rust_name("crate::model", "MultipartField")
536+
+ " for "
537+
+ &name
538+
+ "{",
539+
)
540+
+ indented(
541+
line(unit() + "fn to_multipart_field(&self) -> String {")
542+
+ indented(line("serde_json::to_string(self).unwrap()"))
543+
+ line("}")
544+
+ NewLine
545+
+ line(unit() + "fn mime_type(&self) -> &'static str {")
546+
+ indented(line(r#""application/json""#))
547+
+ line("}"),
548+
)
549+
+ line("}");
531550

532551
Ok(code)
533552
}

0 commit comments

Comments
 (0)