@@ -29,9 +29,6 @@ pub fn parse_request_body(
2929 FnArg :: Typed ( PatType { ty, .. } ) => {
3030 if let Type :: Path ( type_path) = ty. as_ref ( ) {
3131 let path = & type_path. path ;
32- if path. segments . is_empty ( ) {
33- return None ;
34- }
3532
3633 // Check the last segment (handles both Json<T> and vespera::axum::Json<T>)
3734 let segment = path. segments . last ( ) . unwrap ( ) ;
@@ -93,13 +90,27 @@ mod tests {
9390 use insta:: { assert_debug_snapshot, with_settings} ;
9491 use rstest:: rstest;
9592 use std:: collections:: HashMap ;
96- use vespera_core:: schema:: { SchemaRef , SchemaType } ;
93+
94+ #[ rstest]
95+ #[ case( "String" , true ) ]
96+ #[ case( "str" , true ) ]
97+ #[ case( "&String" , true ) ]
98+ #[ case( "&str" , true ) ]
99+ #[ case( "i32" , false ) ]
100+ #[ case( "Vec<String>" , false ) ]
101+ #[ case( "!" , false ) ]
102+ fn test_is_string_like_cases ( #[ case] ty_src : & str , #[ case] expected : bool ) {
103+ let ty: Type = syn:: parse_str ( ty_src) . expect ( "type parse failed" ) ;
104+ assert_eq ! ( is_string_like( & ty) , expected) ;
105+ }
97106
98107 #[ rstest]
99108 #[ case:: json( "fn test(Json(payload): Json<User>) {}" , true , "json" ) ]
100109 #[ case:: string( "fn test(just_string: String) {}" , true , "string" ) ]
101110 #[ case:: str( "fn test(just_str: &str) {}" , true , "str" ) ]
102111 #[ case:: i32( "fn test(just_i32: i32) {}" , false , "i32" ) ]
112+ #[ case:: vec_string( "fn test(just_vec_string: Vec<String>) {}" , false , "vec_string" ) ]
113+ #[ case:: self_ref( "fn test(&self) {}" , false , "self_ref" ) ]
103114 fn test_parse_request_body_cases (
104115 #[ case] func_src : & str ,
105116 #[ case] has_body : bool ,
@@ -113,23 +124,4 @@ mod tests {
113124 assert_debug_snapshot!( body) ;
114125 } ) ;
115126 }
116-
117- #[ test]
118- fn test_parse_request_body_text_plain_schema ( ) {
119- let func: syn:: ItemFn = syn:: parse_str ( "fn test(body: &str) {}" ) . unwrap ( ) ;
120- let arg = func. sig . inputs . first ( ) . unwrap ( ) ;
121- let body = parse_request_body ( arg, & HashMap :: new ( ) , & HashMap :: new ( ) )
122- . expect ( "expected request body" ) ;
123-
124- let media = body
125- . content
126- . get ( "text/plain" )
127- . expect ( "expected text/plain content" ) ;
128-
129- if let SchemaRef :: Inline ( schema) = media. schema . as_ref ( ) . expect ( "schema expected" ) {
130- assert_eq ! ( schema. schema_type, Some ( SchemaType :: String ) ) ;
131- } else {
132- panic ! ( "expected inline schema" ) ;
133- }
134- }
135127}
0 commit comments