Closed
Description
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.");
}
}
Actual Result:
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "string",
"format": "uuid"
}
}
},
Expected Result:
"requestBody": {
"content": {
"application/x-www-form-urlencoded": {
"schema": {
"type": "object",
"properties": {
"test_id": {
"type": "string",
"format": "uuid"
}
},
"required": [
"test_id"
]
}
}
},
Metadata
Metadata
Assignees
Labels
No labels