tempest-framework
tempest-framework copied to clipboard
[Bug]: Support json bodies in requests
Description
When trying to send a json payload to a tempest controller, the requests body isn't set to an array (I believe this is how the laminas-diactoros package works, or atleast according to https://stackoverflow.com/a/73671455), which causes errors when doing validation or accessing the properties on a "custom" reqeust.
When I added something like this in the router dispatch method it seems to work, but I guess its not the best solution:
/** @var PsrRequest $request */
if ($request->getHeader('content-type')[0] === 'application/json') {
$request = $request->withParsedBody(json_decode($request->getBody()->getContents()));
}
Benefits
Well, the ability to build json apis
Yeah this should definitely work. I'll look into it!
Fix will be included in alpha.6