You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is called without deserializing the body Stream using WoohooLabs\Yin\JsonApi\Serializer\JsonDeserializer. Because the stream is based on php://input, once it was read, you never get those bytes back (without maybe rewinding... but I haven't got that to work). So if you then try to call $jsonApi->request->getParsedBody() or $jsonApi->request->getResource(), this will then give you no content.
Yin unfortunately can't use the deserializer in this case because we are trying to provide error (debug) information about a possibly malformed JSON content. However, the problem could be mitigated by doing something similar in RequestValidator::validateJsonBody() to what is done by JsonSerializer: https://github.com/woohoolabs/yin/blob/master/src/JsonApi/Serializer/JsonSerializer.php#L31
I think this is the right way to fix your problem. What do you think about it?
That looks like a good solution to me!
I tried the rewind at some points in the code but that wasn't yet giving me the right behaviour yet, so hopefully doing it at that point in the above way will solve it.
What did I do?
Using
qpautrat/woohoolabs-yin-bundle
, which providesJsonApi $jsonApi
, in Symfony:What did I expect to happen:
Outputs the "data":
What actually happens:
null
Workaround:
The cause here is in
WoohooLabs\Yin\JsonApi\Negotiation\RequestValidator::validateJsonBody()
doing:This is called without deserializing the body
Stream
usingWoohooLabs\Yin\JsonApi\Serializer\JsonDeserializer
. Because the stream is based onphp://input
, once it was read, you never get those bytes back (without maybe rewinding... but I haven't got that to work). So if you then try to call$jsonApi->request->getParsedBody()
or$jsonApi->request->getResource()
, this will then give you no content.First filed at
qpautrat/woohoolabs-yin-bundle
(qpautrat/woohoolabs-yin-bundle#19) but deemed an upstream issue.The text was updated successfully, but these errors were encountered: