You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I have a REST API with Spring MVC. One REST controller has a method with only one parameter. It has a PostMapping with consumes set to "application/x-www-form-urlencoded". The generated openapi definition says, that the request body is of type String and directly contains the value of the parameter, in my case a UUID. There is no key-value pair like i had expected. If I use the button "Try it out" in the Swagger UI I get a bad request response.
[org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'test_id' for method parameter type UUID is not present]
Steps to reproduce the behavior
spring-boot 3.4.5
springdoc-openapi-starter-webmvc-ui 2.8.8 (2.8.6)
Code-Example
@RestController
@Validated
public class DemoController {
@PostMapping(path = "/api/test", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public Result postSingleParameter(@RequestParam(name = "test_id") @NotNull final UUID testId) {
return new Result("Test", "Just a simple test.");
}
}
The text was updated successfully, but these errors were encountered:
mum-viadee
changed the title
Issues with POST Request with only one parameter
Issues with POST Request, application/x-www-form-urlencoded and only one parameter
May 9, 2025
I saw that I used the incorrect parameter annotation (@BeanParam rather than @FormParam) and with the correction swagger-core seems to behave as expected. So more investigation is necessary.
Most likely a corner case that hasn't been covered here?
Describe the bug
I have a REST API with Spring MVC. One REST controller has a method with only one parameter. It has a PostMapping with consumes set to "application/x-www-form-urlencoded". The generated openapi definition says, that the request body is of type String and directly contains the value of the parameter, in my case a UUID. There is no key-value pair like i had expected. If I use the button "Try it out" in the Swagger UI I get a bad request response.
[org.springframework.web.bind.MissingServletRequestParameterException: Required request parameter 'test_id' for method parameter type UUID is not present]
Steps to reproduce the behavior
Code-Example
Actual Result:
Expected Result:
The text was updated successfully, but these errors were encountered: