-
Notifications
You must be signed in to change notification settings - Fork 19
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
Collection response + snake case / camelCase issue #17
Comments
@guiguiboy looks like a bug. Great information to dive in an fix this. |
I'm facing a similar issue here. @nilportugues you think you might be able to look into this or do you expect a pull request? In the last case, you happen to have a pointer where in the code to look for a solution? |
Yeah sure you can do a PR. I'll be happy to merge. You can set alias for all fields to force camelCase in the mapping files. |
The camel case to underscore method is used all over the place, not that easy to refactor, so I tried to use the property alias trick in mapping file with no luck, would you please show an example how it should work? Thanks |
ok I made 3 PRs to make this happen, initially I only make sure that Symfony consumes config for this, and that this config is passed on correctly. Currently this only supports Please let me know if this needs further work. |
@nilportugues Any luck with this PR? |
Hello,
First of all, thanik you for your work.
I am currently using your bundle for my REST API.
I am currently facing an issue with 2 routes that exports the same kind of objects (user objects):
For the list route, I use the following mapping file :
In my controller, I retrieve a list of users which I output as you described in your doc. In the response, I have :
I was expecting to retrieve the user objects direcly in the "data" node but it's available in the "included" node.
What configuration do I need to use to have such output ?
I also noticed another thing concerning the keys attributes. As you can see above, the attributes names in the "included" section are in camelcase (firstName, lastLogin, ...).
But when I execute the serializer on my route to retrieve a single instance of User, I get :
As you can see, the names are transformed in snake case.
it is due to the call in JsonAPiTransformer::serialization.
It calls DataAttributesHelper::setResponseDataAttributes($this->mappings, $value) which in turn calls the method transformToValidMemberName.
But could this behavior be configurable ? Because my parser must now be aware of the snake case and the camelCase to construct my user object.
Thanks for your help.
The text was updated successfully, but these errors were encountered: