Challenge - 5 Problems
OpenAPI @Operation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
What is the purpose of the @Operation annotation's description attribute?
In Spring Boot with OpenAPI, what does the
description attribute inside the @Operation annotation provide?Attempts:
2 left
💡 Hint
Think about what users reading API docs would need to understand about an endpoint.
✗ Incorrect
The
description attribute in @Operation provides a human-friendly explanation of the API endpoint's purpose. This helps users understand the endpoint when viewing the generated OpenAPI documentation.❓ component_behavior
intermediate1:30remaining
How does the @Operation description appear in the generated OpenAPI docs?
Given a Spring Boot controller method annotated with
@Operation(description = "Fetch all products"), where will this description appear?Attempts:
2 left
💡 Hint
Consider where detailed descriptions usually show up in API docs.
✗ Incorrect
The
description attribute content appears as a detailed explanation under the endpoint's method in Swagger UI, helping users understand what the endpoint does beyond the summary.📝 Syntax
advanced2:00remaining
Identify the correct usage of @Operation with description and summary
Which of the following code snippets correctly uses
@Operation to set both summary and description attributes?Spring Boot
public class ProductController { @Operation(???) public List<Product> getAllProducts() { return List.of(); } }
Attempts:
2 left
💡 Hint
Remember Java annotation syntax uses = for attributes.
✗ Incorrect
In Java annotations, attributes are set using
attributeName = value. Option A correctly uses this syntax. Options A and D use invalid syntax, and option A swaps summary and description values incorrectly.🔧 Debug
advanced2:00remaining
Why does this @Operation description not show in Swagger UI?
A developer wrote this code but the description does not appear in Swagger UI:
@Operation(description = "Get user details")
@GetMapping("/user/{id}")
public User getUser(@PathVariable String id) { ... }
What is the most likely reason?Attempts:
2 left
💡 Hint
Think about what generates the Swagger UI docs.
✗ Incorrect
If the OpenAPI or Swagger dependencies are missing or misconfigured, annotations like @Operation won't be processed, so descriptions won't appear. The attribute name is correct, annotation order does not matter, and return type does not affect description display.
❓ state_output
expert2:30remaining
What is the output in Swagger UI for this @Operation annotation?
Consider this Spring Boot controller method:
@Operation(summary = "Create user", description = "Creates a new user with given details.")
@PostMapping("/users")
public ResponseEntity createUser(@RequestBody User user) {
// implementation
return ResponseEntity.ok(user);
}
What will a user see in the Swagger UI for this endpoint?Attempts:
2 left
💡 Hint
Think about how Swagger UI displays summary and description from @Operation.
✗ Incorrect
Swagger UI uses the summary as the main title for the endpoint and shows the description as a detailed explanation below it. Both attributes are displayed by default.