-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
SerializerhasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.
Description
Serializer's documentation explains that we can specify a context specific to normalization or denormalization using normalizationContext
and denormalizationContext
keys in Yaml configuration:
https://github.com/symfony/symfony-docs/blob/6.4/serializer.rst?plain=1#L523-L524
# config/serializer/person.yaml
App\Model\Person:
attributes:
createdAt:
contexts:
- normalizationContext: { datetime_format: 'Y-m-d' }
denormalizationContext: { datetime_format: !php/const \DateTime::RFC3339 }
In the other hand, the YamlFileLoader
is looking for normalization_context
and denormalization_context
keys:
if ($context = $line['normalization_context'] ?? false) {
$attributeMetadata->setNormalizationContextForGroups($context, $groups);
}
if ($context = $line['denormalization_context'] ?? false) {
$attributeMetadata->setDenormalizationContextForGroups($context, $groups);
}
Links above are for 6.4
but it seems to be there from the beginning, nothing changed in the code. Confusion may be due to the name of the corresponding attribute.
Metadata
Metadata
Assignees
Labels
SerializerhasPRA Pull Request has already been submitted for this issue.A Pull Request has already been submitted for this issue.