Performance: Grouping APIs by tags
This affects the API documentation load time and client-side rendering speed when browsing grouped endpoints.
@RestController @RequestMapping("/api/users") @Tag(name = "Users", description = "User management APIs") public class UserController { @GetMapping("") public List<User> getUsers() { ... } @PostMapping("") public User createUser() { ... } } @RestController @RequestMapping("/api/orders") @Tag(name = "Orders", description = "Order management APIs") public class OrderController { @GetMapping("") public List<Order> getOrders() { ... } }
@RestController @RequestMapping("/api") public class UserController { @GetMapping("/users") public List<User> getUsers() { ... } @PostMapping("/users") public User createUser() { ... } @GetMapping("/orders") public List<Order> getOrders() { ... } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Flat list of all endpoints | High number of DOM nodes | Multiple reflows due to large layout | High paint cost from many elements | [X] Bad |
| Grouped endpoints by tags | Fewer DOM nodes initially | Single reflow per group expansion | Lower paint cost with smaller visible sets | [OK] Good |
@Tag annotation in Spring Boot controllers?@RestController
@Tag(name = "Orders")
public class OrderController {
@GetMapping("/orders")
public List<String> getOrders() { return List.of("order1", "order2"); }
}/orders endpoint?@RestController
@Tag(name = "Products")
public class ProductController {
@GetMapping("/products")
public List<String> getProducts() { return List.of("prod1", "prod2"); }
@Tag(name = "Special")
@GetMapping("/products/special")
public List<String> getSpecialProducts() { return List.of("special1"); }
}@RestController
@Tag(name = "Users")
public class UserController {
@GetMapping("/users")
public List<String> getUsers() { return List.of("user1", "user2"); }
}
@RestController
@Tag(name = "Admins")
public class AdminController {
@GetMapping("/admins")
public List<String> getAdmins() { return List.of("admin1"); }
}Pass the test and this pattern moves unknown