Skip to content

v1.4.0 - Zero-Boilerplate @AutoResponse & Class-Level Security Features

Latest

Choose a tag to compare

@PasinduOG PasinduOG released this 28 Feb 22:56
3d2ef8a

🚀 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 @AutoResponse to 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 final ApiResponse.
  • String Safety: Safely intercepts and serializes raw String returns into JSON format using the internal ObjectMapper, completely avoiding ClassCastException conflicts with Spring's native StringHttpMessageConverter.
  • Smart Bypassing: Intelligently skips wrapping if the method already returns an ApiResponse, ResponseEntity, or an RFC 9457 ProblemDetail.

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.

  • **@AutoTrim and @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 String fields 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.java documentation for the new advice package.
  • Completely updated README.md with new features, examples, and version history.
  • Enhanced Javadocs across configuration classes to reflect class-level annotation support.

What's Changed

Full Changelog: v1.3.0...v1.4.0