Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add a description to the API operation using @Operation.
Spring Boot
@Operation(description = "[1]") public ResponseEntity<String> getHello() { return ResponseEntity.ok("Hello World"); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the actual return value as description
Leaving description empty
Using unrelated text
✗ Incorrect
The @Operation annotation's description attribute should describe what the API operation does, such as 'Returns a greeting message'.
2fill in blank
mediumComplete the code to import the correct package for @Operation annotation.
Spring Boot
import [1]; @Operation(description = "Fetch user details") public User getUser() { return new User(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Spring or Java EE packages instead of Swagger's
Misspelling the package name
Omitting the import
✗ Incorrect
The @Operation annotation is from the package io.swagger.v3.oas.annotations.Operation used for OpenAPI documentation.
3fill in blank
hardFix the error in the @Operation annotation to correctly add a summary.
Spring Boot
@Operation([1] = "Get all products") public List<Product> getProducts() { return productService.findAll(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'description' instead of 'summary' for short text
Using unsupported attribute names
Syntax errors in annotation
✗ Incorrect
The correct attribute to add a short summary in @Operation is 'summary', not 'description' or others.
4fill in blank
hardFill both blanks to add a description and a summary to the @Operation annotation.
Spring Boot
@Operation(summary = "[1]", description = "[2]") public ResponseEntity<Void> deleteUser(Long id) { userService.delete(id); return ResponseEntity.noContent().build(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping summary and description texts
Using unrelated texts
Leaving blanks empty
✗ Incorrect
The summary is a short phrase like 'Delete a user', and the description is a longer explanation like 'Removes a user by ID'.
5fill in blank
hardFill all three blanks to add summary, description, and tags to the @Operation annotation.
Spring Boot
@Operation(summary = "[1]", description = "[2]", tags = {"[3]"}) @GetMapping("/orders") public List<Order> listOrders() { return orderService.getAll(); }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated tags
Leaving tags empty
Mixing summary and description
✗ Incorrect
Summary is a short phrase, description explains the operation, and tags categorize the API endpoint.