0
0
Spring Bootframework~10 mins

@Operation annotation for descriptions in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AHello World
BReturns a greeting message
CAPI endpoint
DGet method
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the actual return value as description
Leaving description empty
Using unrelated text
2fill in blank
medium

Complete 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'
Aio.swagger.v3.oas.annotations.Operation
Borg.springframework.web.bind.annotation.Operation
Cjavax.ws.rs.Operation
Dorg.springframework.boot.Operation
Attempts:
3 left
💡 Hint
Common Mistakes
Using Spring or Java EE packages instead of Swagger's
Misspelling the package name
Omitting the import
3fill in blank
hard

Fix 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'
Avalue
Btitle
Csummary
Ddescription
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'description' instead of 'summary' for short text
Using unsupported attribute names
Syntax errors in annotation
4fill in blank
hard

Fill 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'
ADelete a user
BRemoves a user by ID
CFetch user info
DCreates a new user
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping summary and description texts
Using unrelated texts
Leaving blanks empty
5fill in blank
hard

Fill 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'
AList orders
BReturns all orders in the system
Corders
Dusers
Attempts:
3 left
💡 Hint
Common Mistakes
Using unrelated tags
Leaving tags empty
Mixing summary and description