🚀 What's New in v1.4.0
This release introduces major quality-of-life improvements, focusing on reducing controller boilerplate and making security features easier to apply across large DTOs.
🎁 Zero-Boilerplate with @AutoResponse
Tired of wrapping every return object in ResponseEntity<ApiResponse<T>>? With the new @AutoResponse annotation, you can now return raw DTOs directly from your controllers!
- Flexible Granularity: Apply
@AutoResponseto an entire Controller class (ElementType.TYPE) or specifically on individual endpoints (ElementType.METHOD). - Intelligent Status Codes: Custom status codes set via
@ResponseStatus(e.g.,201 Created) are automatically preserved and reflected in the finalApiResponse. - String Safety: Safely intercepts and serializes raw
Stringreturns into JSON format using the internalObjectMapper, completely avoidingClassCastExceptionconflicts with Spring's nativeStringHttpMessageConverter. - Smart Bypassing: Intelligently skips wrapping if the method already returns an
ApiResponse,ResponseEntity, or an RFC 9457ProblemDetail.
Example:
@RestController
@RequestMapping("/api/users")
@AutoResponse // Applies to all methods!
public class UserController {
@GetMapping("/{id}")
public User getUser(@PathVariable Long id) {
return userService.findById(id); // Automatically wrapped!
}
}🛡️ Class-Level Security Annotations
Applying security annotations to DTOs with dozens of fields just got way easier.
- **
@AutoTrimand@XssCheck**now fully support Class-Level (ElementType.TYPE) placement. - Apply the annotation once at the top of your DTO class, and it will automatically protect ALL
Stringfields within that class! - Fully compatible with existing Field-Level placements—you can even mix and match them!
Example:
@AutoTrim
@XssCheck
public class SecureRegistrationDTO {
// ALL fields below are now automatically trimmed and XSS-validated!
private String username;
private String email;
private String bio;
}📚 Documentation Updates
- Added comprehensive
package-info.javadocumentation for the newadvicepackage. - Completely updated
README.mdwith new features, examples, and version history. - Enhanced Javadocs across configuration classes to reflect class-level annotation support.
What's Changed
- Added error methods to ApiResponse by @PasinduOG in #29
- Feature/v1.4.0 by @PasinduOG in #30
- Dev by @PasinduOG in #31
Full Changelog: v1.3.0...v1.4.0