Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xml validation fails on validateMessageBody for Slim v3, all Requests are instances of ServerRequestInterface. #6

Open
jimmy4fingers opened this issue Oct 10, 2018 · 1 comment

Comments

@jimmy4fingers
Copy link

MessageValidator class:

    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.

@guillemcanal
Copy link
Member

@jimmy4fingers Sorry for the delay, and thanks for reporting this. I'll look at it A.S.A.P. I haven't tested this library against an xml payload at all to be honest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants