Performance: @Parameter and @Schema annotations
These annotations affect the API documentation generation and can impact the build time and bundle size of the generated OpenAPI spec.
Use minimal @Parameter and @Schema annotations only where necessary, rely on defaults and implicit naming. public ResponseEntity<User> getUser(String id) { // method body } public class User { public String id; public String name; }
public ResponseEntity<User> getUser(@Parameter(name = "id", description = "User ID", required = true) String id) { // method body } @Schema(description = "User model") public class User { public String id; public String name; }
| Pattern | Build Time Impact | Spec Size | Runtime Impact | Verdict |
|---|---|---|---|---|
| Detailed @Parameter and @Schema on all fields | High (slows build) | Large (+50-100kb) | None | [X] Bad |
| Minimal annotations, rely on defaults | Low (faster build) | Small | None | [OK] Good |
@Parameter annotation in Spring Boot APIs?@Parameter annotation is used to add descriptive information about method parameters in API endpoints.@Parameter?@Parameter annotation uses the attribute description to add text about the parameter.description correctly; others use invalid attribute names.@Parameter(description = "User's age", required = true) int age
required = true have in API documentation?required = true flag indicates that the parameter must be provided by the API caller.@Schema annotation:@Schema(description = "User's email", required = "true") private String email;
required attribute expects a boolean value, not a string.required = "true" is incorrect; it should be required = true without quotes.@Schema annotation usage is correct?maxLength expect an integer, and nullable expects a boolean.nullable = true is needed, and maxLength should be 50 as an integer.Pass the test and this pattern moves unknown