Scrivio Interview library
LeadershipAdvanced5 min read · updated 12 November 2026

Teams build REST controllers in very different styles: paths, status codes, paging, errors. How would you create consistency across 80 services?

Consistency across 80 services comes from making the right way the easy way and checking it automatically. I would publish a short API guideline with examples for paths, status codes, paging, errors and versioning, move teams to API-first OpenAPI specs that are linted in CI with Spectral rules taken from the guideline, ship a shared starter with the standard error and paging components, review new public APIs, and measure compliance so we fix the most used APIs first.

Why this question is asked

With a handful of services, inconsistent APIs are an annoyance. With 80, they become a real cost: every client team writes special code for each service's errors and paging, and every new developer has to learn the quirks again. Interviewers ask this at a senior level to see whether we can create consistency without becoming a bottleneck or writing a document nobody reads. In this answer, we will look at what inconsistency costs, write the guideline, enforce it with linting, back it with shared code, add a light review, and measure the result.

1What Inconsistency Costs

Picture three services. One answers a missing order with 404 and a JSON error, one with 200 and {"success": false}, and one with 500 and an HTML page. One pages with page and size, one with offset and limit, one with a cursor. A client that calls all three needs three error handlers and three paging loops, and every bug report starts with figuring out which convention this service uses.

Across 80 services, that friction slows every integration and hides real errors, because monitoring that counts 5xx responses cannot see a failure reported as 200. The goal of consistency is not beauty; it is that a client written for one service works with the next one with little change.

2Write a Short Guideline With Examples

The guideline should be short enough to read in twenty minutes and full of examples, because people copy examples, not rules. It covers resource paths (plural nouns, kebab-case, no verbs except for actions like /orders/{id}/cancel), status codes and when to use each, the error format, paging, filtering and sorting parameters, dates and money, and versioning and deprecation.

YAML
# From the guideline: the standard error body (RFC 9457 problem details)
HTTP/1.1 404 Not Found
Content-Type: application/problem+json
{
"type": "https://api.example.com/problems/order-not-found",
"title": "Order not found",
"status": 404,
"detail": "Order 42 does not exist",
"instance": "/orders/42"
}
# Standard paging: GET /orders?page=0&size=50&sort=createdAt,desc
{ "content": [ ... ], "page": { "size": 50, "number": 0, "totalElements": 1234, "totalPages": 25 } }

Choosing RFC 9457 problem details for errors is a good example of picking an existing standard over inventing our own: Spring supports it out of the box with ProblemDetail and ErrorResponse, so the shared starter becomes smaller.

3Enforce It With API-First Specs and Linting

A guideline that is only checked by people will drift. So each service publishes an OpenAPI spec, preferably written first and reviewed before code, and CI lints it with Spectral, a linter for OpenAPI files. Each rule in the guideline that can be checked by a machine becomes a Spectral rule in a shared ruleset.

YAML
# .spectral.yaml shared by all services
extends: ["spectral:oas"]
rules:
paths-kebab-case:
given: "$.paths[*]~"
then: { function: pattern, functionOptions: { match: "^(/[a-z0-9-]+|/\\{[a-zA-Z]+\\})+$" } }
severity: error
errors-use-problem-json:
given: "$.paths[*][*].responses[?(@property >= '400')].content"
then: { field: "application/problem+json", function: truthy }
severity: warn
# CI: spectral lint openapi.yaml --ruleset .spectral.yaml -> fails the build on errors
Step throughHow an API change is checked
  1. Team edits the OpenAPI specBefore or with the code
  2. Spectral lints against the shared rulesPaths, errors, paging, naming
  3. Breaking change against last release?oasdiff comparison
    YesNeeds a new version or reviewNoContinue
  4. New public API?First external exposure
    YesAPI review with the guildNoMerge and publish the spec
  5. Spec published to the catalogueClients generate code from it

5 steps in order. Play them, or step through them one at a time.

Notice the severities. New rules start as warnings so existing services are not blocked overnight, and become errors once most services comply. A breaking-change check, for example oasdiff comparing the spec with the last released one, catches removed fields or changed types in the same pipeline.

4Back the Rules With Shared Code

The easiest way to make every service return the same error format is to give them the code. A company Spring Boot starter can contain a @RestControllerAdvice that maps common exceptions to problem details, a paging response type, Jackson settings for dates and money, and a filter that adds a correlation id. A team adds one dependency and gets the standard behaviour.

The starter must be owned by a team that keeps it current with Spring Boot versions, otherwise teams will avoid it to stay on new versions. Keeping it small, a few classes, helps.

5Review New Public APIs and Measure Compliance

For new public or cross-team APIs, a short review by a group of experienced API designers, an API guild, catches what linting cannot: naming that does not match the domain, resources that are too chatty, or an awkward model. The review looks at the spec, takes days not weeks, and is not needed for internal changes that pass the linter.

Then we measure. The lint results of all 80 specs give a compliance score per service. Combined with traffic data from the gateway, we can see which non-compliant APIs are most used, and fix those first, because that is where clients feel the pain. A dashboard reviewed every quarter keeps the topic visible without anyone policing teams by hand.

6Follow-up questions

What if a team cannot change an old API without breaking clients?

Leave the old version as it is and apply the guideline to the next version, or add standard behaviour in a backwards-compatible way, such as adding the problem+json content type when the client asks for it. Compliance targets should count new and changed endpoints first.

Code-first teams do not write specs. How do they fit in?

They can generate the spec from code with springdoc-openapi during the build and lint the generated file. It is less reviewable before coding, but it still gives consistent checks and a published contract.

7Conclusion

In this answer, we saw that consistency across many services is mainly about lowering the cost for clients. A short guideline with examples sets the conventions for paths, status codes, paging, errors and versioning. API-first OpenAPI specs with a shared Spectral ruleset and breaking-change checks in CI enforce them, a small company starter provides the error and paging code, reviews cover new public APIs, and compliance is measured so the most used APIs get fixed first.

What to say in the interviewAbout 80 seconds aloud

Open with

I'd treat it as making the right way the easy way, then checking it automatically. First, a short API guideline, readable in twenty minutes, with concrete examples for paths, status codes, the error format, paging, filtering and versioning.

Then, if they want more

For errors I'd adopt RFC 9457 problem details, since Spring supports ProblemDetail natively. Second, every service publishes an OpenAPI spec, ideally written first, and CI lints it with a shared Spectral ruleset built from the guideline, plus a breaking-change check against the last release.

New rules start as warnings and become errors once most services comply, so we don't block everyone overnight. Third, a small company starter gives teams the standard exception advice, paging type and Jackson settings, so compliance is one dependency rather than a rewrite. It needs an owner who keeps it on current Boot versions.

Fourth, a quick API review for new public or cross-team APIs, focused on design questions a linter can't judge. And finally, measurement: lint results per service combined with gateway traffic, so we fix the most used non-compliant APIs first, and a quarterly look at the dashboard. That way consistency improves steadily without a central team becoming a bottleneck.

About this answer

Last updated
12 November 2026
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.
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 "Teams build REST controllers in very different styles: paths, status codes, paging...": https://scrivio-interview-library.netlify.app/spring-boot/rest-controllers/d174f12bce/