|
25 | 25 | use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; |
26 | 26 | use ApiPlatform\Metadata\Util\ClassInfoTrait; |
27 | 27 | use ApiPlatform\Symfony\Security\ResourceAccessCheckerInterface; |
28 | | -use ApiPlatform\Util\ClassInfoTrait; |
29 | 28 | use ApiPlatform\Util\CloneTrait; |
30 | 29 | use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; |
31 | 30 | use Symfony\Component\PropertyAccess\PropertyAccess; |
|
43 | 42 | use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; |
44 | 43 | use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; |
45 | 44 | use Symfony\Component\Serializer\Normalizer\NormalizerInterface; |
46 | | -use Symfony\Component\Serializer\Serializer; |
47 | 45 |
|
48 | 46 | /** |
49 | 47 | * Base item normalizer. |
@@ -707,7 +705,9 @@ protected function normalizeRelation(ApiProperty $propertyMetadata, ?object $rel |
707 | 705 | throw new LogicException(sprintf('The injected serializer must be an instance of "%s".', NormalizerInterface::class)); |
708 | 706 | } |
709 | 707 |
|
710 | | - $normalizedRelatedObject = $this->serializer->normalize($relatedObject, $format, $context); |
| 708 | + $relatedContext = $context; |
| 709 | + unset($relatedContext['force_resource_class']); |
| 710 | + $normalizedRelatedObject = $this->serializer->normalize($relatedObject, $format, $relatedContext); |
711 | 711 | if (!\is_string($normalizedRelatedObject) && !\is_array($normalizedRelatedObject) && !$normalizedRelatedObject instanceof \ArrayObject && null !== $normalizedRelatedObject) { |
712 | 712 | throw new UnexpectedValueException('Expected normalized relation to be an IRI, array, \ArrayObject or null'); |
713 | 713 | } |
|
0 commit comments