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: core/configuration.md
+6-3Lines changed: 6 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -64,7 +64,7 @@ api_platform:
64
64
65
65
# Enable the docs.
66
66
enable_docs: true
67
-
67
+
68
68
# Enable the data collector and the WebProfilerBundle integration.
69
69
enable_profiler: true
70
70
@@ -157,7 +157,7 @@ api_platform:
157
157
swagger:
158
158
# The active versions of OpenAPI to be exported or used in the swagger_ui. The first value is the default.
159
159
versions: [2, 3]
160
-
160
+
161
161
# The swagger API keys.
162
162
api_keys: []
163
163
# The name of the header or query parameter containing the API key.
@@ -192,7 +192,7 @@ api_platform:
192
192
url:
193
193
194
194
swagger_ui_extra_configuration:
195
-
# Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing).
195
+
# Controls the default expansion setting for the operations and tags. It can be 'list' (expands only the tags), 'full' (expands the tags and operations) or 'none' (expands nothing).
196
196
docExpansion: list
197
197
# If set, enables filtering. The top bar will show an edit box that you can use to filter the tagged operations that are shown.
When submitting data you can collect denormalization errors using the [COLLECT_DENORMALIZATION_ERRORS option](https://symfony.com/doc/current/components/serializer.html#collecting-type-errors-while-denormalizing).
581
+
582
+
It can be done directly in the `#[ApiResource]` attribute (or in the operations):
583
+
584
+
```php
585
+
<?php
586
+
// api/src/Entity/Book.php
587
+
namespace App\Entity;
588
+
589
+
use ApiPlatform\Metadata\ApiResource;
590
+
591
+
#[ApiResource(
592
+
collectDenormalizationErrors: true
593
+
)]
594
+
class Book
595
+
{
596
+
public ?bool $boolean;
597
+
public ?string $property1;
598
+
}
599
+
```
600
+
601
+
If the submitted data has denormalization errors, the HTTP status code will be set to `422 Unprocessable Content` and the response body will contain the list of errors:
"hydra:description": "boolean: This value should be of type bool.\nproperty1: This value should be of type string.",
609
+
"violations": [
610
+
{
611
+
"propertyPath": "boolean",
612
+
"message": "This value should be of type bool.",
613
+
"code": "0"
614
+
},
615
+
{
616
+
"propertyPath": "property1",
617
+
"message": "This value should be of type string.",
618
+
"code": "0"
619
+
}
620
+
]
621
+
}
622
+
```
623
+
624
+
You can also enable collecting of denormalization errors globally in the [Global Resources Defaults](https://api-platform.com/docs/core/configuration/#global-resources-defaults).
0 commit comments