Bean Validation transforms Object RequestParam into @RequestBody

Ioana R.

I have the following:

 @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
 public ResponseEntity<LoginResponse> getLoginStatus(@Valid LoginRequest loginRequest){
        //some stuff here
 }

The loginRequest paramater is a @RequestParam, but, because it is a custom object, the @RequestParam annotation in front of the object is not needed. The problem is that when any bean-validation annotation is put in front of the custom object, the object is transformed into a body parameter(@RequestBody), but we want to validate the object as request param, not body param.

Could anyone help me, please?

miagy

The reason why the LoginRequest attributes became part of the RequestBody, and not of RequestParameters anymore, is due to springfox-swagger version 2.6.1. Upgrading to version 2.7.0 fixed this issue for us.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

how to receive a json object with @RequestBody or @RequestParam

@RequestBody not parsing request into object for validation

How to send a custom validation Json object for the requestbody?

Validation of JSON Object With @Valid and @Requestbody in SpringBoot

What is difference between @RequestBody and @RequestParam?

How to use @RequestBody and @RequestParam together

spring validation for requestparam not working

Spring Boot List of Object Bean Validation

Spring @GetMapping with @RequestParam and @RequestBody fails with HttpMessageNotReadableException

How to pass body @RequestBody and @RequestParam in same request

Spring RequestBody optional validation

ObjectAssign transforms bool to object

Spring RequestParam validation in Kotlin is not working

How to map @RequestParam to object?

Custom Object as a @RequestParam

Why map transforms in object in MongoDB?

Cascaded bean validation 2.0 not working with nested object inside Map

Spring annotations : form validation of a bean internal object attribute using thymeleaf

"Required request body is missing" when changing from RequestParam to RequestBody

@RequestBody not binding complex object

Converting @RequestBody to an object

Flattening RequestParam Object in OpenApi 3

can we receive @RequestParam in object

Spring boot REST: cannot test validation of @RequestParam

can't apply custom validation to requestParam

Bean Validation XML entire bean

Spring @RequestBody validation issue using @Valid annotation

Hibernate Object as @RequestBody in AngularJS and Spring

@RequestBody Object does not deserialize automatically