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
- Adding SpringDoc to Your Project
- Documenting Endpoints and Models
- Customizing the OpenAPI Spec
- Swagger UI