Examples and error responses
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
make the docs useful, not just generated.
Planned topics
- Add a short
descriptionto each operation and field. - Add realistic examples for requests and responses so newcomers can copy them.
- Document the error responses (
400,404,409) with the Problem Details shape. - Undocumented errors force clients to guess.
- Use
@ApiResponseon operations, or a shared configuration for common errors.
Draft outline details
Demonstration
@Operation(summary = "Get a product")
@ApiResponse(responseCode = "404", description = "Product not found")
@GetMapping("/{id}")
ProductResponse get(@PathVariable long id) { ... }Check your understanding
Why document 404?
Show answer
Clients need to know what can go wrong and what it looks like.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.