public ResponseEntity<User> getUser(@Parameter(description = "User ID") @PathVariable String id) {
// method body
}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.
public class User { @Schema(required = true, maxLength = 50) private String name; }
The @Schema annotation attributes require correct data types: 'required' is boolean, 'maxLength' is int. Passing strings or wrong types causes errors.
public class Product { @Schema(example = 12345) private String code; }
The example attribute in @Schema expects a String value. Providing an integer causes a type mismatch error during startup.
@Parameter annotates method parameters to add metadata for API docs, while @Schema annotates data model classes or fields to define their schema details.
@Parameter(description = "Item identifier") @Schema(example = "42", required = true) @PathVariable String id
Using both @Parameter and @Schema on a method parameter enriches the OpenAPI docs with description, example, and required status together.
