1/21
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What does HATEOAS stand for?
Hypermedia As The Engine Of Application State.
What is the purpose of HATEOAS in REST APIs?
It’s a principle in REST APIs where a Client doesn’t need to know everything upfront. Instead, it can discover what actions are available by following hyperlinks.
To allow clients to discover actions and resources via hyperlinks without hardcoding URIs.
What is HAL in the context of HATEOAS?
HAL (Hypertext Application Language) is a standard for adding hyperlinks to your JSON data.
It’s a way to make HATEOAS practical using JSON
What is a “self” link in HAL?
A link pointing to the current resource, useful for bookmarking or navigation.
Which HTTP method is used in Spring Boot to return HAL links?
GET
(Spring Boot does not use OPTIONS
for HATEOAS discovery).
how do you make a class capable of holding HAL links in Spring Boot?
Extend RepresentationModel<T>
.
What method is used to add links to a model object?
add(...)
from RepresentationModel
.
What is the function of linkTo(...).withSelfRel()
?
It creates a “self” link pointing to the current resource’s URL.
What is the purpose of the @JsonProperty
annotation in Jackson?
To map a Java field/method to a JSON property with a different name.
What does HAL use to structure lists of related objects?
The _embedded
property.
What does the CollectionModel<T>
class do in Spring HATEOAS?
It wraps a collection of objects and allows links to be added to the collection itself.
In HAL+JSON, what is _links
used for?
It contains all the hypermedia links associated with a resource.
How can you delete or edit a resource using HAL+JSON?
By sending a DELETE
or PUT
request to the URI in its self
link.
What are the two main client options for handling HAL+JSON?
1. Parse as raw JSON using JsonNode
2. Map to Java classes with Jackson
What does objectMapper.readTree(...)
do?
Parses a JSON string into a JsonNode
tree structure.
What does the getDataItems(JsonNode)
method do?
Recursively walks a JSON tree and prints all values.
How do you pretty-print a JsonNode
with Jackson?
Use objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(node)
.
What does the getData(...)
method in the client do?
Sends an HTTP GET
request and returns the JSON response as a string.
What Spring Boot dependency is required to use RepresentationModel
and HAL?
spring-hateoas
What is the content type of HAL+JSON responses?
application/hal+json
What is the purpose of the new
link in a HAL response?
It indicates where a new resource (e.g., planet or moon) can be created via POST.
What’s the benefit of using HATEOAS over hardcoded URIs in clients?
It makes the client loosely coupled to the API and more adaptable to changes.