Closed raress96 closed 4 years ago
This is supposed to work, I'll give it a try soon.
A GET
item operation is actually mandatory (by design), even if sometimes you might get away with it.
Let's see if we could avoid IRI generation in your case... Can you share a stack trace please?
@teohhanhui It is required, but if I set the output
to false
and use this on a DTO with the messenger integration, I expect it to not be required since there is no need to return something in the response, hence the code 202 (maybe it works with code 204? but I haven't tested it yet).
And also, the most important thing is that this example is from the documentation and it worked perfectly fine before ApiPlatform 2.4.3, so it must be a bug introduced in that version.
I also got bitten by this when upgrading to 2.4.3
in addition to setting output
to false
, another use case for me was to have a dto class in output
but without any itemOperations
for the resource, for an endpoint that handle generic uploads and has some details on the processed file in the response, although it does not have a resource with an ID to GET, so no iri.
This previously worked because it skipped the iri generations, as I returned the output dto from the data persister, and apparently it worked leveraging a bug that got fixed (https://github.com/api-platform/core/commit/431cf6f8dc9cb8bd2fdc08ba3017c8255638cb92). I now see it wasnt the intended behaviour and so I'm not asking to reintroduce spacebar heating (as in https://xkcd.com/1172/), however I'd consider a way to avoid the IRI generation both when there is or not and output, maybe we could check if the resource has a GET
item operation?
Otherwise is there another solutions for these use cases? I understand I could build directly a response in a custom controller or even in the data persister, however I'd still like to let the SerializeListener
and RespondListener
do what they are good at, without duplicating their logic by manually composing a response for specific endpoints.
@raresserban looks like settings itemOperations: []
generate this bug.
I created a ticket https://github.com/api-platform/core/issues/3501
Indeed the safe way to diable item operations is to do:
/**
* @ApiResource(
* itemOperations={
* "get"={
* "method"="GET",
* "controller"=NotFoundAction::class,
* "read"=false,
* "output"=false,
* },
* },
* )
*/
As documented at the end of this section.
I have the following YAML configuration as per the docs:
This worked in Api Platform 2.4.2 fine, but does no longer work in Api Platform 2.4.3, generating the title error, even though the
output
is set to false.This is exactly like the documentation mentions but does not work correctly: https://api-platform.com/docs/core/messenger/