-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dispatcher / transformer supporting SerializerInterface out of the box #158
Comments
If I get your point correctly, do you ask why some parts of apitte-skeleton, such as https://github.com/contributte/apitte-skeleton/blob/master/app/model/Api/Dispatcher/JsonDispatcher.php, is not part of apitte/core? |
Yes |
Basically what apitte/core allows me out of the box is piece of array *** while in some random sandbox which I didn't know about there is full featured serializer that allows me to return any DTO as response object from controller method. Those response objects can be nested and everything is typed and lovely. This option with serializer should be recommended default available in apitte/core <3 |
Before I discovered apitte sandbox I did it myself by extending I don't know why you decided to put everything to dispatcher I don't think it is it's work to serialize responses. Aren't there transformers to do this job? I'm not nitpicking btw even if it may sound like so. It just confused me when I saw your solution for the first time. I thought my solution was bad usage of apitte and that I should do it in different way. |
Closing here. Feel free to open it. |
I noticed that https://github.com/contributte/apitte-skeleton/ implements it's own JsonDispatcher to use symfony/serializer. Also it somehow allows to return any value Object (DTO?) in controller that will be passed directly into serializer.
I did the same thing in my project based on nette/sandbox by extending
DecoratedDispatcher::negotiate()
which allows onlyarray
,scalar
andIResponseEntity
so I added is_object condition and returned newObjectEntity
wrapping my DTO which is already present in this repository but unsused. Then I created my ownSerializerTransformer
that transformed this TDO / value object into json exactly the same way you do inJsonDispatcher
of apitte-skeleton.My question is why is this part of apitte-skeleton and not supported out of the box by this library? Am I missing something? My point is that I migrated (basically I copied few folders into apitte-skeleton) my API I started to work at 2 weeks ago to contributte/api-skeleton and without changing much it magically started to work. So where's the difference between soluton in skeleton and my tinker solution?
The text was updated successfully, but these errors were encountered: