codecutout / JsonApiSerializer

JsonApiSerializer supports configurationless serializing and deserializing objects into the json:api format (http://jsonapi.org).
MIT License
113 stars 46 forks source link

Convert type names in the same way as property names #43

Open cmeeren opened 6 years ago

cmeeren commented 6 years ago

Property names are, by default, converted from e.g. SomePropertyName to somePropertyName. However, type names are converted from SomeTypeName to sometypename. I know the type names can be overridden using a Type property, but I think the serializer by default should convert type names in the same way as property names. (In particular, since I use a custom NamingStrategy, see #41, I would expect the type name to be converted using the same stragety.)

alex-davies commented 6 years ago

I do regret having the default behaviour toLower() rather than camelCasing, unfortunately to change it now is a breaking change so would have to bump the major version.

I do like the idea of using the NamingStrategy to generate the names. It would have to be a different NamingStrategy than the one used for properties as you need to know if you are naming a type or a property which is quite reasonable that you want to have different strategies.

The current behaviour of having to extend a ResourceObjectConverter to change naming is not something I like much, but is available to you if you need to get unblocked.

Feel free to raise a PR, otherwise you will have to wait a few weeks until I can find some time to look further into this.

cmeeren commented 6 years ago

Thanks. Swamped at the moment, so I'll wait. :)