@@ -50,7 +50,7 @@ pub async fn mod_file_with_struct_body(Json(body): Json<StructBody>) -> String {
5050 format ! ( "name: {}, age: {}" , body. name, body. age)
5151}
5252
53- #[ derive( Deserialize , Schema ) ]
53+ #[ derive( Deserialize , Schema , Debug ) ]
5454pub struct StructBodyWithOptional {
5555 pub name : Option < String > ,
5656 pub age : Option < u32 > ,
@@ -62,3 +62,37 @@ pub async fn mod_file_with_struct_body_with_optional(
6262) -> String {
6363 format ! ( "name: {:?}, age: {:?}" , body. name, body. age)
6464}
65+
66+ #[ derive( Deserialize , Schema ) ]
67+ #[ serde( rename_all = "camelCase" ) ]
68+ pub struct ComplexStructBody {
69+ pub name : String ,
70+ pub age : u32 ,
71+ pub nested_struct : StructBodyWithOptional ,
72+ pub array : Vec < String > ,
73+ pub map : HashMap < String , String > ,
74+ pub nested_array : Vec < StructBodyWithOptional > ,
75+ pub nested_map : HashMap < String , StructBodyWithOptional > ,
76+ pub nested_struct_array : Vec < StructBodyWithOptional > ,
77+ pub nested_struct_map : HashMap < String , StructBodyWithOptional > ,
78+ pub nested_struct_array_map : Vec < HashMap < String , StructBodyWithOptional > > ,
79+ pub nested_struct_map_array : HashMap < String , Vec < StructBodyWithOptional > > ,
80+ }
81+
82+ #[ vespera:: route( post, path = "/complex-struct-body" ) ]
83+ pub async fn mod_file_with_complex_struct_body ( Json ( body) : Json < ComplexStructBody > ) -> String {
84+ format ! (
85+ "name: {}, age: {}, nested_struct: {:?}, array: {:?}, map: {:?}, nested_array: {:?}, nested_map: {:?}, nested_struct_array: {:?}, nested_struct_map: {:?}, nested_struct_array_map: {:?}, nested_struct_map_array: {:?}" ,
86+ body. name,
87+ body. age,
88+ body. nested_struct,
89+ body. array,
90+ body. map,
91+ body. nested_array,
92+ body. nested_map,
93+ body. nested_struct_array,
94+ body. nested_struct_map,
95+ body. nested_struct_array_map,
96+ body. nested_struct_map_array
97+ )
98+ }
0 commit comments