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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,36 @@
18
18
* Metadata: Fix identifier support when using an interface as resource class
19
19
* Metadata: the HTTP method is now always uppercased
20
20
* Allow to disable listeners per operation (fix handling of empty request content)
21
+
22
+
Previously, empty request content was allowed for any `POST` and `PUT` operations. This was an unsafe assumption which caused [other problems](https://github.com/api-platform/core/issues/2731).
23
+
24
+
If you wish to allow empty request content, please add `"deserialize"=false` to the operation's attributes. For example:
25
+
26
+
```php
27
+
<?php
28
+
// api/src/Entity/Book.php
29
+
30
+
use ApiPlatform\Core\Annotation\ApiResource;
31
+
use App\Controller\PublishBookAction;
32
+
33
+
/**
34
+
* @ApiResource(
35
+
* itemOperations={
36
+
* "put_publish"={
37
+
* "method"="PUT",
38
+
* "path"="/books/{id}/publish",
39
+
* "controller"=PublishBookAction::class,
40
+
* "deserialize"=false,
41
+
* },
42
+
* },
43
+
* )
44
+
*/
45
+
class Book
46
+
{
47
+
```
48
+
49
+
You may also need to add `"validate"=false` if the controller result is `null` (possibly because you don't need to persist the resource).
50
+
21
51
* Return the `204` HTTP status code when the output class is set to `null`
22
52
* Be more resilient when normalizing non-resource objects
23
53
* Replace the `data` request attribute by the return of the data persister
0 commit comments