-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Built-in method validation does not work with Boot auto-configuration #31082
Comments
@rstoyanchev See #31045 where I worked on WebFlux type conversion refinements to get a bad request response instead of an internal server error. |
Thanks for the sample. For built-in method validation to work, there needs be a globally configured
By the way, the built-in method validation does not need a method-level @RestController
@RequestMapping(produces = MediaType.APPLICATION_JSON_VALUE, path = "/method")
public class MethodLevelController {
@GetMapping(path = "/{id}")
public Mono<Void> getEntity(@PathVariable @Positive Long id) {
return Mono.empty();
}
} |
I've made updates on the Spring Framework side with 832b49f, c441fc7, and 4bf54a2, which completes the work necessary on the Spring Framework side. There is also a follow-up change required on the Spring Boot side, see spring-projects/spring-boot#37081. I expect that will be done for 3.2 M3. I am closing this issue for now, but I'll test with the sample after the Boot issue is done. If necessary we can reopen this issue. |
There are two issues with the new feature of validating method parameters.
@Validated
is used on the class level. If it is used on method level, nothing happens at all. The documentation suggest to remove class level annotation and use a method level annotation instead.spring-framework/framework-docs/modules/ROOT/pages/web/webflux/controller/ann-validation.adoc
Lines 33 to 37 in 1e30997
Tested with Spring Boot 3.2.0-M1 and Spring Framework 6.1.0-M3 and 6.1.0-M4. Sample project is attached.
spring-boot-reactive-demo.zip
The text was updated successfully, but these errors were encountered: