gurunathkumar79
7 years agoNew Contributor
Swagger UI- Swagger UI is Sending Blank RequestBody Even though it is specified as optional
Hi All,
I have written a post request which is accepting requestbody as false.
@PostMapping(value = "/testPost") @ResponseStatus(ACCEPTED) @ApiOperation(value = "Testing post", notes = "") public void testPost(@RequestBody(required = false) @Valid Pojo pojo, @RequestHeader(value = "type") String type) { }
When iam trying to hit the endpoint using swagger-ui,swagger is sending an empty request body as shown below
'{}'.
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'type: test' -d '{}' 'http://localhost:8080/testpost'
Seems like there is issue with swagger UI while handling if requestbody is false.
Any inputs or have faced similar kind of issue?