REST API Versioning — Spring Technical Interview Questions & Answers
URI, header and query-param versioning strategies.
REST API Versioning
- REST API Versioning (sb) is a Spring topic. In plain words you use it for GET /api/marks/{roll} in a campus API. Don’t start with a slogan — start with that picture.
- Smallest example: @RestController + service call. Type it, run it, and say what you see. If you can do that from memory, you know REST API Versioning (sb).
- From the example next to this theory: URI, header and query-param versioning strategies.
- Trap: business logic inside the controller. Fix that before you talk about advanced Spring.
- Viva: what is REST API Versioning (sb)? Then show @RestController + service call. Then name the trap.
Technical Interview Tip: What is REST API Versioning (sb)? Show this: @RestController + service call. Trap: business logic inside the controller.
Code Examples for REST API Versioning
REST API Versioning — working example
// Topic: REST API Versioning
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
class TopicController {
@GetMapping("/api/topic")
String topic() {
return "Spring Boot: REST API Versioning";
}
}REST API Versioning: GET /api/topic returns this title string.
How to Explain REST API Versioning to an Interviewer
What is REST API Versioning (sb)?
Used for GET /api/marks/{roll} a campus API Not just the heading
Give one small example of REST API Versioning (sb).
@RestController + service call URI, header and query-param versioning strategies
What mistake do beginners make with REST API Versioning (sb)?
business logic inside the controller Show the fix
Where do you use REST API Versioning (sb)?
a campus API GET /api/marks/{roll}