api-platform / api-platform/core

Set Serialization Groups Manually [feature]

Open
#8,004 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
2.6k
Forks
980
Avg merge
2d 5h
Merged PRs (30d)
48

Description

**Description**

Make it possible to define the serialization group through the request attributes.
Something like this:

**Example**

https://github.com/api-platform/core/blob/22ce6399180f9408f19b0b3c857317d2ddd7ea9d/src/Serializer/SerializerContextBuilder.php#L60

```php
$context = $resourceMetadata->getTypedOperationAttribute($operationType, $attributes[$operationKey], $key, [], true);
if ($context and $context['groups']) {
$serializerContext = $request->attributes->get('_api_serializer_context', []);
$context = array_merge_recursive($context, $serializerContext);
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.