@@ -1346,6 +1346,98 @@ pub fn get_user() -> User {
13461346 assert ! ( value. is_none( ) ) ;
13471347 }
13481348
1349+ #[ test]
1350+ fn test_build_path_items_unknown_http_method ( ) {
1351+ // Test lines 131-134: route with unknown HTTP method is skipped
1352+ let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp dir" ) ;
1353+
1354+ let route_content = r#"
1355+ pub fn get_users() -> String {
1356+ "users".to_string()
1357+ }
1358+ "# ;
1359+ let route_file = create_temp_file ( & temp_dir, "users.rs" , route_content) ;
1360+
1361+ let mut metadata = CollectedMetadata :: new ( ) ;
1362+ metadata. routes . push ( RouteMetadata {
1363+ method : "INVALID" . to_string ( ) ,
1364+ path : "/users" . to_string ( ) ,
1365+ function_name : "get_users" . to_string ( ) ,
1366+ module_path : "test::users" . to_string ( ) ,
1367+ file_path : route_file. to_string_lossy ( ) . to_string ( ) ,
1368+ signature : "fn get_users() -> String" . to_string ( ) ,
1369+ error_status : None ,
1370+ tags : None ,
1371+ description : None ,
1372+ } ) ;
1373+
1374+ let doc = generate_openapi_doc_with_metadata ( None , None , None , & metadata) ;
1375+
1376+ // Route with unknown HTTP method should be skipped entirely
1377+ assert ! (
1378+ doc. paths. is_empty( ) ,
1379+ "Route with unknown HTTP method should be skipped"
1380+ ) ;
1381+ }
1382+
1383+ #[ test]
1384+ fn test_build_path_items_unknown_method_skipped_valid_kept ( ) {
1385+ // Test that unknown methods are skipped while valid routes are kept
1386+ let temp_dir = TempDir :: new ( ) . expect ( "Failed to create temp dir" ) ;
1387+
1388+ let route_content = r#"
1389+ pub fn get_users() -> String {
1390+ "users".to_string()
1391+ }
1392+
1393+ pub fn create_users() -> String {
1394+ "created".to_string()
1395+ }
1396+ "# ;
1397+ let route_file = create_temp_file ( & temp_dir, "users.rs" , route_content) ;
1398+ let file_path = route_file. to_string_lossy ( ) . to_string ( ) ;
1399+
1400+ let mut metadata = CollectedMetadata :: new ( ) ;
1401+ // Invalid method route
1402+ metadata. routes . push ( RouteMetadata {
1403+ method : "CONNECT" . to_string ( ) ,
1404+ path : "/users" . to_string ( ) ,
1405+ function_name : "get_users" . to_string ( ) ,
1406+ module_path : "test::users" . to_string ( ) ,
1407+ file_path : file_path. clone ( ) ,
1408+ signature : "fn get_users() -> String" . to_string ( ) ,
1409+ error_status : None ,
1410+ tags : None ,
1411+ description : None ,
1412+ } ) ;
1413+ // Valid method route
1414+ metadata. routes . push ( RouteMetadata {
1415+ method : "POST" . to_string ( ) ,
1416+ path : "/users" . to_string ( ) ,
1417+ function_name : "create_users" . to_string ( ) ,
1418+ module_path : "test::users" . to_string ( ) ,
1419+ file_path,
1420+ signature : "fn create_users() -> String" . to_string ( ) ,
1421+ error_status : None ,
1422+ tags : None ,
1423+ description : None ,
1424+ } ) ;
1425+
1426+ let doc = generate_openapi_doc_with_metadata ( None , None , None , & metadata) ;
1427+
1428+ // Only the valid POST route should appear
1429+ assert_eq ! ( doc. paths. len( ) , 1 ) ;
1430+ let path_item = doc. paths . get ( "/users" ) . unwrap ( ) ;
1431+ assert ! (
1432+ path_item. post. is_some( ) ,
1433+ "Valid POST route should be present"
1434+ ) ;
1435+ assert ! (
1436+ path_item. get. is_none( ) ,
1437+ "Invalid method route should be skipped"
1438+ ) ;
1439+ }
1440+
13491441 #[ test]
13501442 fn test_generate_openapi_with_unparseable_definition ( ) {
13511443 // Test line 42: syn::parse_str fails with invalid Rust syntax
0 commit comments