Skip to content

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

@jimmy4fingers

Description

@jimmy4fingers

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions