rrezartprebreza/spring-boot-skills / skills/spring-boot-3/hateoas
hateoas
VerifiedUse when adding hypermedia links to REST responses, building self-describing APIs, or implementing Spring HATEOAS. Use when you see EntityModel, CollectionModel, or RepresentationModel in the project.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 5.7 KB |
| agents/openai.yaml | config | 182 B |
| examples/bad-hateoas-controller.java | other | 1.6 KB |
| examples/good-hateoas-controller.java | other | 2.0 KB |
| templates/OrderModelAssembler.java | other | 1.9 KB |
examples/bad-hateoas-controller.java
View on GitHub// BAD — hardcoded URLs, all links regardless of state, no assembler, missing self link
@RestController
@RequestMapping("/api/v1/orders")
public class OrderController {
@Autowired
private OrderService orderService;
@GetMapping("/{id}")
public OrderResponse getById(@PathVariable UUID id) {
Order order = orderService.findById(id);
OrderResponse response = OrderResponse.from(order);
// Returns plain DTO — no HATEOAS links at all!
return response;
}
@GetMapping("/{id}/with-links")
public Map<String, Object> getWithLinks(@PathVariable UUID id) {
Order order = orderService.findById(id);
return Map.of(
"data", OrderResponse.from(order),
"_links", Map.of(
// BAD: Hardcoded URLs instead of linkTo(methodOn(...))
"self", "http://localhost:8080/api/v1/orders/" + id,
"orders", "http://localhost:8080/api/v1/orders",
// BAD: All action links regardless of order state
"cancel", "http://localhost:8080/api/v1/orders/" + id + "/cancel",
"ship", "http://localhost:8080/api/v1/orders/" + id + "/ship",
"confirm", "http://localhost:8080/api/v1/orders/" + id + "/confirm"
)
);
}
@GetMapping
public List<OrderResponse> list(Pageable pageable) {
// BAD: Returns plain list — no CollectionModel, no pagination links
return orderService.findAll(pageable).getContent().stream()
.map(OrderResponse::from)
.toList();
}
// BAD: Link-building logic scattered in controller instead of assembler
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementation | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirements | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallback | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions always | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |