json_api_assert icon indicating copy to clipboard operation
json_api_assert copied to clipboard

Serializer type defaults to underscore, not dash

Open codyjroberts opened this issue 9 years ago • 2 comments

This is a bit pedantic, but ja_serializer and ember-data default to dasherized types per json-api.org recommendation although the spec allows for both. I'm currently specifying the type with s/2 to get around this. Any reason for this? If not I'll throw a PR your way to add to my growing list. 😅

codyjroberts avatar Jul 28 '16 19:07 codyjroberts

I'd prefer to not impose opinions on the serializer and have it just 1-to-1. However, we could offer an option to force to underscore

s(data, underscore: true)

We could take a step further and pull from the App config if you don't want to set this for every function call

config :json_api_assert, key_transform: fn(key) -> String.replace(key, "_", "-") end

bcardarella avatar Jul 28 '16 19:07 bcardarella

I think I like the App config solution a bit more. I assume, possibly naively, that in most cases if someone has to change a serialized attribute once they'll have to do it multiple times.

codyjroberts avatar Jul 28 '16 20:07 codyjroberts