Quick revision
The short answer
My recommendation is OpenAPI contracts with plain JSON as the default for public APIs, plus a small, standard set of links where they earn their keep: pagination and the state transitions a resource allows. Full HAL hypermedia with Spring HATEOAS should be a deliberate choice for the few APIs whose clients really discover actions at runtime. Whichever style a team picks, the guild should standardize errors (RFC 9457 problem details), pagination and naming, and lint every contract in CI.
What to remember
In this answer, we saw that hypermedia lets the server own the rules about allowed actions but helps only when clients follow links, which most public clients do not. OpenAPI with plain JSON has the tooling and the expectations of consumers on its side, so it is the right default, with a hybrid of standard links for pagination and state transitions. We chose per API using the client population, versioning, skills and the cost of HAL in other languages, and we made consistency the real goal: RFC 9457 errors, one pagination and naming style, and contracts linted in CI.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
My recommendation is OpenAPI contracts with plain JSON as the default for public APIs, plus a small, standard set of links where they earn their keep: pagination and the state transitions a resource allows. Full HAL hypermedia with Spring HATEOAS should be a deliberate choice for the few APIs whose clients really discover actions at runtime. Whichever style a team picks, the guild should standardize errors (RFC 9457 problem details), pagination and naming, and lint every contract in CI.
Background to this question
API style debates tend to run forever because both sides are partly right. Hypermedia is the original idea of REST and it solves a real problem, while OpenAPI is what most consumers, gateways and code generators expect today. A senior engineer is asked this question to see whether they can turn a debate of principles into criteria that a guild can apply to each API. In this answer, we will recap what hypermedia and OpenAPI each give us, look at what the client population actually does, go through the criteria, describe the hybrid most organizations end up with, and finish with the standards that matter more than the choice itself.
1A Quick Recap of the Two Styles
Hypermedia means the server tells the client what it can do next by putting links in each response. HAL, the Hypertext Application Language, is a simple JSON format for this: a resource carries a _links object with named links such as self, next or cancel. Spring HATEOAS is the Spring project that builds these responses for us, so a controller returns an EntityModel or a CollectionModel instead of a plain object.
OpenAPI is a machine-readable description of an API: every path, method, request body, response and error, written in YAML or JSON. With plain JSON and OpenAPI, the client learns the URLs and rules from the contract at build time, not from the response at runtime. The response itself is just the data.
Notice what the cancel link does. The rule for when an order may be cancelled lives on the server, and the client only has to check whether the link is there. That is the real promise of hypermedia: the server can change the rule without a client release.
2What Hypermedia Buys and Who Actually Uses It
Hypermedia helps most in two situations. The first is when clients should discover which actions are allowed, for example a back office UI that shows a Cancel button only when the cancel link is present. The second is when state rules change often on the server side, such as refund windows that differ per country and per product.
But there is a catch. The benefit exists only if clients follow links instead of building URLs themselves, and in practice few public clients do. Most consumers copy a URL template from the documentation, generate a client from a contract, or write a curl command, and then they ignore _links entirely. A link that nobody follows still costs us response size, documentation effort and a dependency on a format that clients in Python, Go or JavaScript must parse by hand or with a smaller library ecosystem than the Java one.
3The Criteria We Apply to Each API
Instead of one rule for all public APIs, the guild should give teams a short set of questions. Who are the clients: our own UIs, a few partners, or thousands of unknown developers? How do we version: do we promise long-lived compatibility, or ship new major versions? What are the team's skills, and can we support HAL for non-Java clients with examples and SDKs? And how often do the state rules change?
| Criterion | Points to plain JSON + OpenAPI | Points to hypermedia |
|---|---|---|
| Client population | Many external developers, generated SDKs | Our own UIs or a few close partners |
| Tooling needs | Gateways, codegen, contract tests, docs portals | Generic clients that follow links |
| State rules | Stable lifecycle, rarely changes | Rules change often per market or product |
| Versioning | Explicit versions in the contract | Evolve by adding and removing links |
| Non-Java clients | Any language reads plain JSON | HAL parsing must be supported per language |
The table summarizes how those answers usually point. Notice that the answer is about the consumers, not about the server framework we happen to like.
4Why OpenAPI Wins as the Default
OpenAPI with plain JSON has much stronger tooling. We can generate client libraries in a dozen languages, import the contract into an API gateway to validate requests, run contract tests that fail the build when a field disappears, and publish documentation automatically. Consumers expect it: when a partner integrates, the first thing they ask for is the OpenAPI file.
So for a public API with an unknown client population, the default should be OpenAPI first. In a Spring Boot service, springdoc-openapi can generate the document from the controllers, or the team can write the contract first and generate server interfaces from it; contract-first is easier to review in a guild because the change shows up as a diff in a YAML file.
5The Hybrid Most Organizations Choose
A hybrid gives us most of the value of both. The contract is OpenAPI and the payload is plain JSON, but we standardize a small number of links. Collections carry next and prev links, so clients never compute page URLs, and resources with a lifecycle carry links for the transitions currently allowed, documented in the contract as an optional links object.
This keeps generated clients working, lets UI teams hide buttons based on links, and costs very little. Teams with a strong case for full HAL, such as an internal workflow API consumed by our own UI, can still use Spring HATEOAS and document the HAL media type in their contract.
6What to Standardize Whatever We Choose
The style matters less than consistency across 50 or 100 APIs. The guild should fix an error format, and the obvious choice is RFC 9457 problem details, the standard JSON shape with type, title, status, detail and instance. Spring Framework 6 supports it directly through ProblemDetail and ErrorResponse, and Spring Boot can switch it on for the built-in errors with spring.mvc.problemdetails.enabled=true.
The guild should also choose one pagination style (cursor-based for large or changing collections), one naming convention for fields and paths, one date format, and one versioning policy. Then it should enforce them automatically: lint every contract in CI with a tool such as Spectral and a shared rule set, and fail the build on breaking changes by comparing the contract with the last released one. Rules that only live in a wiki page drift within months.
7Follow-up questions
How would you measure whether clients use links?
We make link following visible in our logs. The cleanest trick is to put something in the linked URLs that clients cannot easily guess, such as an opaque cursor in next links, and then count how many page requests use cursors versus hand-built page numbers. For action links, we compare requests to the action URL from clients that previously fetched the resource with those from clients that never did. Adding a client id header, required by the gateway, lets us break this down per consumer. After a quarter of data we know whether links are a feature or decoration.
Is an API without hypermedia really REST?
Strictly, by Roy Fielding's definition, hypermedia is one of the constraints, so a plain JSON API is HTTP-based rather than fully RESTful. In an interview I acknowledge that and then say the label matters less than the outcome: clear contracts, stable evolution and good tooling for the clients we actually have.
8Conclusion
In this answer, we saw that hypermedia lets the server own the rules about allowed actions but helps only when clients follow links, which most public clients do not. OpenAPI with plain JSON has the tooling and the expectations of consumers on its side, so it is the right default, with a hybrid of standard links for pagination and state transitions. We chose per API using the client population, versioning, skills and the cost of HAL in other languages, and we made consistency the real goal: RFC 9457 errors, one pagination and naming style, and contracts linted in CI.
Open with
My recommendation would be OpenAPI first with plain JSON as the default for public APIs, and hypermedia only where it pays for itself. Hypermedia is valuable when clients should discover allowed actions and when state rules change often on the server, but most public consumers generate a client or copy URLs from docs and never follow links, so full HAL mostly adds cost, especially for non-Java clients.
Then, if they want more
OpenAPI gives us code generation, gateway validation, contract tests and documentation, and it is what partners ask for. So I would propose a hybrid: the contract is OpenAPI, and we standardize a small links object for pagination and for the state transitions a resource currently allows, documented in the contract.
A team with a real case, such as an internal workflow API used by our own UI, can still use Spring HATEOAS. I would give teams criteria rather than a rule: client population, versioning strategy, team skills and the cost of supporting HAL in other languages.
And whatever is chosen, the guild should standardize the things that matter more: RFC 9457 problem details for errors, one pagination style, naming and versioning rules, with Spectral linting and breaking-change checks in CI. To know whether links are used, I would measure it with opaque cursors and per-client logs.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Framework 6
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Boot reference
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "An API guild debates whether all public REST APIs should use hypermedia (HAL with Spring...": https://scrivio-interview-library.netlify.app/spring-boot/spring-projects/b67bb4b687/