@@ -1285,9 +1285,15 @@ mod tests {
12851285 /// Unit test: Verify OpenAPI operations are propagated during nesting
12861286 #[ test]
12871287 fn test_openapi_operations_propagated_during_nesting ( ) {
1288- async fn list_users ( ) -> & ' static str { "list users" }
1289- async fn get_user ( ) -> & ' static str { "get user" }
1290- async fn create_user ( ) -> & ' static str { "create user" }
1288+ async fn list_users ( ) -> & ' static str {
1289+ "list users"
1290+ }
1291+ async fn get_user ( ) -> & ' static str {
1292+ "get user"
1293+ }
1294+ async fn create_user ( ) -> & ' static str {
1295+ "create user"
1296+ }
12911297
12921298 // Create nested router with multiple routes
12931299 // Note: We use separate routes since MethodRouter doesn't support chaining
@@ -1302,26 +1308,42 @@ mod tests {
13021308 let spec = app. openapi_spec ( ) ;
13031309
13041310 // Verify /api/v1/users path exists with GET
1305- assert ! ( spec. paths. contains_key( "/api/v1/users" ) , "Should have /api/v1/users path" ) ;
1311+ assert ! (
1312+ spec. paths. contains_key( "/api/v1/users" ) ,
1313+ "Should have /api/v1/users path"
1314+ ) ;
13061315 let users_path = spec. paths . get ( "/api/v1/users" ) . unwrap ( ) ;
13071316 assert ! ( users_path. get. is_some( ) , "Should have GET operation" ) ;
13081317
13091318 // Verify /api/v1/users/create path exists with POST
1310- assert ! ( spec. paths. contains_key( "/api/v1/users/create" ) , "Should have /api/v1/users/create path" ) ;
1319+ assert ! (
1320+ spec. paths. contains_key( "/api/v1/users/create" ) ,
1321+ "Should have /api/v1/users/create path"
1322+ ) ;
13111323 let create_path = spec. paths . get ( "/api/v1/users/create" ) . unwrap ( ) ;
13121324 assert ! ( create_path. post. is_some( ) , "Should have POST operation" ) ;
13131325
13141326 // Verify /api/v1/users/{id} path exists with GET
1315- assert ! ( spec. paths. contains_key( "/api/v1/users/{id}" ) , "Should have /api/v1/users/{{id}} path" ) ;
1327+ assert ! (
1328+ spec. paths. contains_key( "/api/v1/users/{id}" ) ,
1329+ "Should have /api/v1/users/{{id}} path"
1330+ ) ;
13161331 let user_path = spec. paths . get ( "/api/v1/users/{id}" ) . unwrap ( ) ;
1317- assert ! ( user_path. get. is_some( ) , "Should have GET operation for user by id" ) ;
1332+ assert ! (
1333+ user_path. get. is_some( ) ,
1334+ "Should have GET operation for user by id"
1335+ ) ;
13181336
13191337 // Verify path parameter is added
13201338 let get_user_op = user_path. get . as_ref ( ) . unwrap ( ) ;
13211339 assert ! ( get_user_op. parameters. is_some( ) , "Should have parameters" ) ;
13221340 let params = get_user_op. parameters . as_ref ( ) . unwrap ( ) ;
1323- assert ! ( params. iter( ) . any( |p| p. name == "id" && p. location == "path" ) ,
1324- "Should have 'id' path parameter" ) ;
1341+ assert ! (
1342+ params
1343+ . iter( )
1344+ . any( |p| p. name == "id" && p. location == "path" ) ,
1345+ "Should have 'id' path parameter"
1346+ ) ;
13251347 }
13261348
13271349 /// Unit test: Verify nested routes don't appear without nesting
@@ -1331,7 +1353,10 @@ mod tests {
13311353 let spec = app. openapi_spec ( ) ;
13321354
13331355 // Should have no paths (except potentially default ones)
1334- assert ! ( spec. paths. is_empty( ) , "OpenAPI spec should have no paths without routes" ) ;
1356+ assert ! (
1357+ spec. paths. is_empty( ) ,
1358+ "OpenAPI spec should have no paths without routes"
1359+ ) ;
13351360 }
13361361
13371362 /// Unit test: Verify RustApi::nest delegates correctly to Router::nest
@@ -1342,9 +1367,15 @@ mod tests {
13421367 fn test_rustapi_nest_delegates_to_router_nest ( ) {
13431368 use crate :: router:: RouteMatch ;
13441369
1345- async fn list_users ( ) -> & ' static str { "list users" }
1346- async fn get_user ( ) -> & ' static str { "get user" }
1347- async fn create_user ( ) -> & ' static str { "create user" }
1370+ async fn list_users ( ) -> & ' static str {
1371+ "list users"
1372+ }
1373+ async fn get_user ( ) -> & ' static str {
1374+ "get user"
1375+ }
1376+ async fn create_user ( ) -> & ' static str {
1377+ "create user"
1378+ }
13481379
13491380 // Create nested router with multiple routes
13501381 let users_router = Router :: new ( )
@@ -1361,9 +1392,18 @@ mod tests {
13611392 assert_eq ! ( routes. len( ) , 3 , "Should have 3 routes registered" ) ;
13621393
13631394 // Verify route paths
1364- assert ! ( routes. contains_key( "/api/v1/users" ) , "Should have /api/v1/users route" ) ;
1365- assert ! ( routes. contains_key( "/api/v1/users/create" ) , "Should have /api/v1/users/create route" ) ;
1366- assert ! ( routes. contains_key( "/api/v1/users/:id" ) , "Should have /api/v1/users/:id route" ) ;
1395+ assert ! (
1396+ routes. contains_key( "/api/v1/users" ) ,
1397+ "Should have /api/v1/users route"
1398+ ) ;
1399+ assert ! (
1400+ routes. contains_key( "/api/v1/users/create" ) ,
1401+ "Should have /api/v1/users/create route"
1402+ ) ;
1403+ assert ! (
1404+ routes. contains_key( "/api/v1/users/:id" ) ,
1405+ "Should have /api/v1/users/:id route"
1406+ ) ;
13671407
13681408 // Verify route matching works
13691409 match router. match_route ( "/api/v1/users" , & Method :: GET ) {
@@ -1382,7 +1422,11 @@ mod tests {
13821422
13831423 match router. match_route ( "/api/v1/users/123" , & Method :: GET ) {
13841424 RouteMatch :: Found { params, .. } => {
1385- assert_eq ! ( params. get( "id" ) , Some ( & "123" . to_string( ) ) , "Should extract id param" ) ;
1425+ assert_eq ! (
1426+ params. get( "id" ) ,
1427+ Some ( & "123" . to_string( ) ) ,
1428+ "Should extract id param"
1429+ ) ;
13861430 }
13871431 _ => panic ! ( "GET /api/v1/users/123 should be found" ) ,
13881432 }
@@ -1402,8 +1446,12 @@ mod tests {
14021446 /// **Validates: Requirements 6.1, 6.2**
14031447 #[ test]
14041448 fn test_rustapi_nest_includes_routes_in_openapi_spec ( ) {
1405- async fn list_items ( ) -> & ' static str { "list items" }
1406- async fn get_item ( ) -> & ' static str { "get item" }
1449+ async fn list_items ( ) -> & ' static str {
1450+ "list items"
1451+ }
1452+ async fn get_item ( ) -> & ' static str {
1453+ "get item"
1454+ }
14071455
14081456 // Create nested router
14091457 let items_router = Router :: new ( )
@@ -1417,22 +1465,38 @@ mod tests {
14171465 let spec = app. openapi_spec ( ) ;
14181466
14191467 // Verify paths exist
1420- assert ! ( spec. paths. contains_key( "/api/items" ) , "Should have /api/items in OpenAPI" ) ;
1421- assert ! ( spec. paths. contains_key( "/api/items/{item_id}" ) , "Should have /api/items/{{item_id}} in OpenAPI" ) ;
1468+ assert ! (
1469+ spec. paths. contains_key( "/api/items" ) ,
1470+ "Should have /api/items in OpenAPI"
1471+ ) ;
1472+ assert ! (
1473+ spec. paths. contains_key( "/api/items/{item_id}" ) ,
1474+ "Should have /api/items/{{item_id}} in OpenAPI"
1475+ ) ;
14221476
14231477 // Verify operations
14241478 let list_path = spec. paths . get ( "/api/items" ) . unwrap ( ) ;
1425- assert ! ( list_path. get. is_some( ) , "Should have GET operation for /api/items" ) ;
1479+ assert ! (
1480+ list_path. get. is_some( ) ,
1481+ "Should have GET operation for /api/items"
1482+ ) ;
14261483
14271484 let get_path = spec. paths . get ( "/api/items/{item_id}" ) . unwrap ( ) ;
1428- assert ! ( get_path. get. is_some( ) , "Should have GET operation for /api/items/{{item_id}}" ) ;
1485+ assert ! (
1486+ get_path. get. is_some( ) ,
1487+ "Should have GET operation for /api/items/{{item_id}}"
1488+ ) ;
14291489
14301490 // Verify path parameter is added
14311491 let get_op = get_path. get . as_ref ( ) . unwrap ( ) ;
14321492 assert ! ( get_op. parameters. is_some( ) , "Should have parameters" ) ;
14331493 let params = get_op. parameters . as_ref ( ) . unwrap ( ) ;
1434- assert ! ( params. iter( ) . any( |p| p. name == "item_id" && p. location == "path" ) ,
1435- "Should have 'item_id' path parameter" ) ;
1494+ assert ! (
1495+ params
1496+ . iter( )
1497+ . any( |p| p. name == "item_id" && p. location == "path" ) ,
1498+ "Should have 'item_id' path parameter"
1499+ ) ;
14361500 }
14371501}
14381502
0 commit comments