php-json-api
php-json-api copied to clipboard
Naming convention of data attributes keys
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.
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
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