violines / rest-bundle

Symfony Bundle to create REST APIs
MIT License
35 stars 1 forks source link

Allow custom Serializers #129

Closed HellPat closed 3 years ago

HellPat commented 3 years ago

symfony/serializer has many features. Not everybody needs them and often there are more simple options. At the moment you have to use symfony/serializer or replace BodyArgumentResolver as well as SuccessResponseResolver completely.

This is because they depend on Serializer and not an interface which could be replaced with own implementations.

simon-schubert commented 3 years ago

thanks @HellPat ! maybe there is something missing or maybe you misunderstood the code: there is a little wrapper around the serializer to centralize the logic of firing events. It still should be possible to replace the symfony/serializer by implementing the serializer interface from symfony: https://github.com/violines/rest-bundle/blob/b7696354fc5f7d3b01629bf0b29faa13b72ce328/src/Serialize/Serializer.php#L17

It should even work, if you overwrite in your project the "serializer" service key definition.

Unfortunately I think there is no "better" interoperable interface to my knowledge. And inventing an own one, does not sound like a good idea, or?

But I'm open for any suggestion 😄

HellPat commented 3 years ago

Oh sorry, my fault :-) (I overlooked the part where you Inject the SerializerInterface into your own serializer)