@@ -328,26 +328,26 @@ impl<'a> Parser<'a> {
328328 let mut matched_path_params = std:: collections:: HashSet :: new ( ) ;
329329
330330 // Check each path spec parameter
331- for spec_param in & path_spec. params {
331+ for param_name in & path_spec. params {
332332 // Try to find exact match first
333- let exact_match = endpoint. path . iter ( ) . find ( |f| f. name == spec_param . name ) ;
333+ let exact_match = endpoint. path . iter ( ) . find ( |f| & f. name == param_name ) ;
334334
335335 if exact_match. is_some ( ) {
336- matched_path_params. insert ( spec_param . name . clone ( ) ) ;
336+ matched_path_params. insert ( param_name . clone ( ) ) ;
337337 continue ;
338338 }
339339
340340 // Try case-insensitive match
341341 let case_insensitive_match = endpoint
342342 . path
343343 . iter ( )
344- . find ( |f| f. name . to_lowercase ( ) == spec_param . name . to_lowercase ( ) ) ;
344+ . find ( |f| f. name . to_lowercase ( ) == param_name . to_lowercase ( ) ) ;
345345
346346 if let Some ( field) = case_insensitive_match {
347- case_mismatches. push ( ( spec_param . name . clone ( ) , field. name . clone ( ) ) ) ;
347+ case_mismatches. push ( ( param_name . clone ( ) , field. name . clone ( ) ) ) ;
348348 matched_path_params. insert ( field. name . clone ( ) ) ;
349349 } else {
350- missing_params. push ( spec_param . name . clone ( ) ) ;
350+ missing_params. push ( param_name . clone ( ) ) ;
351351 }
352352 }
353353
@@ -358,7 +358,7 @@ impl<'a> Parser<'a> {
358358 let is_case_mismatch = path_spec
359359 . params
360360 . iter ( )
361- . any ( |p| p. name . to_lowercase ( ) == field. name . to_lowercase ( ) ) ;
361+ . any ( |p| p. to_lowercase ( ) == field. name . to_lowercase ( ) ) ;
362362
363363 if !is_case_mismatch {
364364 extra_params. push ( field. name . clone ( ) ) ;
@@ -400,40 +400,12 @@ impl<'a> Parser<'a> {
400400 . join( ", " )
401401 ) ) ;
402402 }
403-
404- // Validate parameter types if specified in path
405- for path_param in & path_spec. params {
406- if path_param. param_type != "str" {
407- // Find the corresponding field in the path block (case-insensitive)
408- if let Some ( field) = endpoint
409- . path
410- . iter ( )
411- . find ( |f| f. name . to_lowercase ( ) == path_param. name . to_lowercase ( ) )
412- {
413- // Check if the types match
414- let expected_type = match path_param. param_type . as_str ( ) {
415- "int" => FieldType :: Number ,
416- "float" => FieldType :: Number ,
417- "bool" => FieldType :: Bool ,
418- _ => FieldType :: Str , // Default to string
419- } ;
420- if field. _type != expected_type {
421- return Err ( format ! (
422- "Type mismatch for path parameter '{}': expected '{}', got '{}'" ,
423- field. name,
424- path_param. param_type,
425- field. _type. as_str( )
426- ) ) ;
427- }
428- }
429- }
430- }
431403 }
432404
433405 Ok ( ( ) )
434406 }
435407
436- fn parse_path ( & mut self ) -> Result < ( String , Vec < PathParameter > ) , String > {
408+ fn parse_path ( & mut self ) -> Result < ( String , Vec < String > ) , String > {
437409 let mut path = String :: new ( ) ;
438410 let mut params = Vec :: new ( ) ;
439411
@@ -464,11 +436,8 @@ impl<'a> Parser<'a> {
464436 path. push_str ( & name) ;
465437 path. push ( '}' ) ;
466438
467- // Add parameter to our list
468- params. push ( PathParameter {
469- name,
470- param_type : "str" . to_string ( ) , // Default type, will be overridden by path block
471- } ) ;
439+ // Add parameter name to our list
440+ params. push ( name) ;
472441 }
473442 TokenType :: Identifier => {
474443 path. push_str ( self . current . lexeme ) ;
@@ -481,7 +450,6 @@ impl<'a> Parser<'a> {
481450
482451 Ok ( ( path, params) )
483452 }
484-
485453 fn consume ( & mut self , expected : TokenType , message : & str ) -> Result < ( ) , String > {
486454 if self . check ( expected) {
487455 self . advance ( ) ;
@@ -551,8 +519,7 @@ mod tests {
551519 assert_eq ! ( route. docs, "Test route line1\n Test route line2" ) ;
552520 assert_eq ! ( route. prefix, "/test/{id}" ) ;
553521 assert_eq ! ( route. params. len( ) , 1 ) ;
554- assert_eq ! ( route. params[ 0 ] . name, "id" ) ;
555- assert_eq ! ( route. params[ 0 ] . param_type, "str" ) ;
522+ assert_eq ! ( route. params[ 0 ] , "id" ) ;
556523
557524 let endpoint = & route. endpoints [ 0 ] ;
558525 assert_eq ! ( endpoint. docs, "Test endpoint" ) ;
@@ -760,7 +727,7 @@ mod tests {
760727 assert_eq ! ( endpoint. path_specs[ 0 ] . method, HttpMethod :: Get ) ;
761728 assert_eq ! ( endpoint. path_specs[ 0 ] . path, "/users/{id}" ) ;
762729 assert_eq ! ( endpoint. path_specs[ 0 ] . params. len( ) , 1 ) ;
763- assert_eq ! ( endpoint. path_specs[ 0 ] . params[ 0 ] . name , "id" ) ;
730+ assert_eq ! ( endpoint. path_specs[ 0 ] . params[ 0 ] , "id" ) ;
764731
765732 assert_eq ! ( endpoint. path_specs[ 1 ] . method, HttpMethod :: Post ) ;
766733 assert_eq ! ( endpoint. path_specs[ 1 ] . path, "/users" ) ;
0 commit comments