public function validateMessageBody(MessageInterface $message, MessageDefinition $definition)
{
if ($message instanceof ServerRequestInterface) {
$bodyString = json_encode((array) $message->getParsedBody());
} else {
$bodyString = (string) $message->getBody();
}
if ($bodyString !== '' && $definition->hasBodySchema()) {
$contentType = $message->getHeaderLine('Content-Type');
$decodedBody = $this->decoder->decode(
$bodyString,
DecoderUtils::extractFormatFromContentType($contentType)
);
$this->validate($decodedBody, $definition->getBodySchema(), 'body');
}
}
The xml in $message->getBody() is being converted to a json string before it's decoded. All requests in Slim v3 are instances of ServerRequestInterface.