Bird
0
0

Identify the error in this usage of @Operation:

medium📝 Debug Q14 of 15
Spring Boot - API Documentation
Identify the error in this usage of @Operation:
@Operation(summary = "Create item", description = 12345)
@PostMapping("/item")
public Item createItem(@RequestBody Item item) { return itemService.save(item); }
AThe <code>@PostMapping</code> annotation is incorrect
BThe summary attribute is missing
CThe method return type should be void
DThe description value must be a string, not a number
Step-by-Step Solution
Solution:
  1. Step 1: Check attribute types in @Operation

    The description attribute must be a string, but 12345 is a number.
  2. Step 2: Verify other parts

    The summary is present, @PostMapping is correct, and return type can be Item.
  3. Final Answer:

    The description value must be a string, not a number -> Option D
  4. Quick Check:

    @Operation attributes require string values [OK]
Quick Trick: Always use quotes for @Operation text values [OK]
Common Mistakes:
  • Passing non-string values to summary or description
  • Confusing HTTP method annotations
  • Expecting void return type for create methods

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes