0PricingLogin
Spring Boot 4 Microservices & REST APIs · Lesson

Documenting Endpoints and Models

Describe operations with annotations.

Going beyond auto-detection

Auto-generated docs are functional but terse. Annotations from io.swagger.v3.oas.annotations let you add human-friendly descriptions, examples and response details.

@Operation

@Operation documents a single endpoint: a short summary and a longer description shown in the UI.

@Operation(summary = "Get a user by id",
           description = "Returns a single user or 404 if not found")
@GetMapping("/users/{id}")
public User get(@PathVariable Long id) {
    return service.find(id);
}

All lessons in this course

  1. Adding SpringDoc to Your Project
  2. Documenting Endpoints and Models
  3. Customizing the OpenAPI Spec
  4. Swagger UI
← Back to Spring Boot 4 Microservices & REST APIs