php-json-api icon indicating copy to clipboard operation
php-json-api copied to clipboard

Naming convention of data attributes keys

Open renz-ken opened this issue 8 years ago • 2 comments

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.

renz-ken avatar Aug 17 '16 05:08 renz-ken

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 avatar Aug 18 '16 14:08 nilportugues

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

nilportugues avatar Aug 18 '16 15:08 nilportugues