denormalizers are no longer aliased as normalizer in 4.4
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 68/100
Línea de trabajo
Start by reviewing commit d36c14c and the service IDs api_platform.jsonld.normalizer.item and api_platform.jsonld.denormalizer.item. Reproduce the issue with the DTO and decorator shown, then verify that decorating the normalizer also affects denormalization as it did in 4.3, without requiring a second decorator.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
API Platform version(s) affected: 4.4.0
Description
Commit d36c14c splits normalizer and denormalizer into dedicated ItemNormalizer and ItemDenormalizer. This causes overwritten decorators to no longer work (docs is also still outdated https://api-platform.com/docs/v4.4/core/serialization/#decorating-a-serializer-and-adding-extra-data-for-symfony)
How to reproduce
Create a serializer that decorates only 'api_platform.jsonld.normalizer.item', it no longer decorates during denormalize.
// small DTO to play with:
class Test
{
public bool $test = false;
}
#[AsDecorator('api_platform.jsonld.normalizer.item')]
class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
{
public function __construct(
#[AutowireDecorated]
private readonly NormalizerInterface&DenormalizerInterface&SerializerAwareInterface $decorated,
) {
}
public function setSerializer(SerializerInterface $serializer): void
{
$this->decorated->setSerializer($serializer);
}
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
{
$result = $this->decorated->denormalize($data, $type, $format, $context);
$result->test = true;
return $result;
}
public function supportsDenormalization(
mixed $data,
string $type,
?string $format = null,
array $context = [],
): bool {
return $this->decorated->supportsDenormalization($data, $type, $format, $context);
}
public function normalize(
mixed $data,
?string $format = null,
array $context = [],
): array|string|int|float|bool|ArrayObject|null {
$result = $this->decorated->normalize($data, $format, $context);
$result['extraProperty'] = true;
return $result;
}
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $this->decorated->supportsNormalization($data, $format, $context);
}
public function getSupportedTypes(?string $format): array
{
return $this->decorated->getSupportedTypes($format);
}
}
Given this setup, I expect normalize to add extraProperty and denormalize to set test to true. In 4.3 this worked, in 4.4 it no longer works and we have to add an extra decorator:
~ #[AsDecorator('api_platform.jsonld.normalizer.item')]
+ #[AsDecorator('api_platform.jsonld.denormalizer.item')]
~ class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
Hence why this is a backwards compatibility break on a minor version (4.4).
Possible Solution
d36c14c should be removed from 4.4 and moved to 5.0
Additional Context
- Lenguaje dominante
- PHP
- Estrellas
- 2.6k
- Forks
- 987
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 90
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de api-platform/core
-
DeserializeProvider calls PartialDenormalizationException::getErrors(), deprecated in Symfony 8.1Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
api-platform/core#8650 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
api-platform/core#8649 ·
Los mantenedores suelen responder en 1 día
-
`OrderExtension` and `OrderFilter` pass string sort directions, deprecated since `doctrine/orm` 3.7Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
api-platform/core#8648 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
api-platform/core#8647 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
api-platform/core#8612 ·
Los mantenedores suelen responder en 1 día
Todos los issues de api-platform/core
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
codeigniter4/CodeIgniter4#10616 ·
Los mantenedores suelen responder en 1 día
-
bug code quality
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
SemanticMediaWiki/SemanticMediaWiki#7149 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
google/site-kit-wp#13825 ·
Los mantenedores suelen responder en 3 días
-
Made by AI module: MCP type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día