nilportugues / php-json-api

JSON API transformer outputting valid (PSR-7) API Responses.
http://nilportugues.com
MIT License
71 stars 35 forks source link

Naming convention of data attributes keys #77

Open renz-ken opened 8 years ago

renz-ken commented 8 years ago

According to the JSON recommendation (http://jsonapi.org/recommendations/#naming) the preferred naming convention is to use hyphens to separate words in keys, eg 'modified-date'. Current implementation of the library has a dependency on nilportugues/php-api-transformer which converts camelCase words to underscore-separated words, eg: 'modifiedDate' to 'modified_date', which leaves no way to conform to the recommendation. It would be great to add an option that allows to choose which transformation logic is applied to the key names.

nilportugues commented 8 years ago

Notice this is a recommendation, not an enforcement.

Yet I agree a parameter could be set to take this into account and allow different conventions

nilportugues commented 8 years ago

Code related to the issue:

Repo https://github.com/nilportugues/php-json-api/blob/master/src/JsonApiTransformer.php#L249

Dependency https://github.com/nilportugues/php-api-transformer/blob/master/src/Transformer/Transformer.php#L121