Core: POST operation should return a body according to swagger, but they don't

Created on 24 Oct 2018  路  6Comments  路  Source: api-platform/core

On a simple POST resource, without modification regarding the body response, I have this generated doc:

image

So I should have the created object on the response. But when I try, I got nothing:

image

I don't know what should be the default behavior, but one of the two sides is wrong.

question

All 6 comments

When I post a new resource to the API, I do indeed get an object returned which is the newly persisted entity. Do you have anything else in your setup that may be interfering? Perhaps it might be worth adding the symfony profiler pack (https://symfony.com/doc/current/profiler.html) to your project and checking what controller is sending the response back?

The called controller is api_platform.action.post_collection, alias of ApiPlatform\Core\Action\PlaceholderAction.

OK so it probably is the event listeners creating the output (which is how API Platform is designed).

Can you replicate this on a new installation of API platform that you can share the repo for? You don't have any listeners that may override the output do you?

ATM I'm still working on the API platform integration. I'll do it when I will go back to this issue. :+1:

It seems to be a serialization issue: https://github.com/api-platform/core/blob/b6898f3958b74e95c4550e91a87105cdfa5874a8/src/EventListener/SerializeListener.php#L72

$controllerResult contains my data, but the serializer returns nothing.

Still investigating.

Ok so the serialization group is wrong. But I don't think it's a direct api-platform issue as the serialization group building is on my own side. Closing.

Was this page helpful?
0 / 5 - 0 ratings