Challenge - 5 Problems
OpenAPI Annotation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
How does @Parameter affect API documentation?
Consider a Spring Boot REST controller method with a parameter annotated by @Parameter(description = "User ID"). What effect does this annotation have on the generated OpenAPI documentation?
Spring Boot
public ResponseEntity<User> getUser(@Parameter(description = "User ID") @PathVariable String id) {
// method body
}Attempts:
2 left
💡 Hint
Think about how @Parameter is used to enhance API documentation metadata.
✗ Incorrect
The @Parameter annotation is used to add metadata like descriptions to method parameters in OpenAPI documentation. It does not affect validation or parameter types directly.
📝 Syntax
intermediate2:00remaining
Correct usage of @Schema to define a model property
Which of the following code snippets correctly uses @Schema to specify that a field is required and has a maximum length of 50 characters?
Spring Boot
public class User { @Schema(required = true, maxLength = 50) private String name; }
Attempts:
2 left
💡 Hint
Check the data types of the annotation attributes.
✗ Incorrect
The @Schema annotation attributes require correct data types: 'required' is boolean, 'maxLength' is int. Passing strings or wrong types causes errors.
🔧 Debug
advanced2:00remaining
Why does this @Schema annotation cause a runtime error?
Given the code snippet below, why does the application fail to start?
public class Product {
@Schema(example = 12345)
private String code;
}
Spring Boot
public class Product { @Schema(example = 12345) private String code; }
Attempts:
2 left
💡 Hint
Check the expected data type for the example attribute in @Schema.
✗ Incorrect
The example attribute in @Schema expects a String value. Providing an integer causes a type mismatch error during startup.
🧠 Conceptual
advanced2:00remaining
Difference between @Parameter and @Schema annotations
Which statement best describes the difference between @Parameter and @Schema annotations in Spring Boot OpenAPI integration?
Attempts:
2 left
💡 Hint
Think about what each annotation targets: parameters vs data models.
✗ Incorrect
@Parameter annotates method parameters to add metadata for API docs, while @Schema annotates data model classes or fields to define their schema details.
❓ state_output
expert3:00remaining
What is the effect of combining @Parameter and @Schema on a method parameter?
Consider this method parameter in a Spring Boot controller:
@GetMapping("/items/{id}")
public Item getItem(
@Parameter(description = "Item identifier")
@Schema(example = "42", required = true)
@PathVariable String id) {
// method body
}
What will be the combined effect on the generated OpenAPI documentation for this parameter?
Spring Boot
@Parameter(description = "Item identifier") @Schema(example = "42", required = true) @PathVariable String id
Attempts:
2 left
💡 Hint
Both annotations add complementary metadata for API documentation.
✗ Incorrect
Using both @Parameter and @Schema on a method parameter enriches the OpenAPI docs with description, example, and required status together.