active_model_serializers
active_model_serializers copied to clipboard
Preserve path when string is camelized
Purpose
In my project I have some cases when I need to make a POST request with nested data. The following data may be provided:
{
"data": {
"type": "offers",
"attributes": {
"bid": { "amount": 1.12, "currency": "USD" }
}
}
}
Bid attribute may have validation errors so the response should provide this information:
{
"errors": [
{ "source": { "pointer": "/data/attributes/bid/amount" }, "detail": "too_low" }
]
}
But when I use camel key transformation I receive /data/attributes/bid::Amount instead of /data/attributes/bid/amount
This PR fixes this behavior for camel and camel_lower key transformations
Changes
In camel and camel_lower key transformations
Caveats
I saw work at https://github.com/rails-api/active_model_serializers/pull/1928 and introduction of case_transform. I can make PR to this gem also.
Related GitHub issues
#1928
Additional helpful information
@sineed, thanks for your PR! By analyzing the history of the files in this pull request, we identified @remear, @dubadub and @iancanderson to be potential reviewers.
So the value is being transformed? that doesn't seem right