hateoas

Featured

Use 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.

AI & Automation 225 stars 37 forks Updated 6 days ago MIT

Install

View on GitHub

Quality Score: 88/100

Stars 20%
78
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Spring HATEOAS ## Dependency ```xml <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-hateoas</artifactId> </dependency> ``` ## When to Add Links - `self` — always, on every resource response - `collection` — link back to the list endpoint - `related resources` — when a client commonly needs to navigate to them - `actions` — links to state transitions (e.g., `cancel`, `ship`) when valid for current state ## Resource Model ```java public class OrderModel extends RepresentationModel<OrderModel> { private final UUID id; private final String status; private final String customerEmail; private final Instant createdAt; // Static factory with links public static OrderModel from(Order order) { OrderModel model = new OrderModel( order.getId(), order.getStatus().name(), order.getCustomerEmail(), order.getCreatedAt() ); // Self link — always model.add(linkTo(methodOn(OrderController.class).getById(order.getId())).withSelfRel()); // Collection link model.add(linkTo(methodOn(OrderController.class).list(null)).withRel("orders")); // Conditional action links based on state if (order.getStatus() == OrderStatus.PENDING) { model.add(linkTo(methodOn(OrderController.class) .cancelOrder(order.getId())).withRel("cancel")); } if (order.getStatus() == OrderStatus.PROCESSING) { ...

Details

Author
rrezartprebreza
Repository
rrezartprebreza/spring-boot-skills
Created
4 months ago
Last Updated
6 days ago
Language
Java
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category