jozo / djangorestframework-camel-case2

Camel case JSON support for Django REST framework
Other
1 stars 4 forks source link

Option to preserve first char as underscore #15

Open jamesjwarren opened 4 years ago

jamesjwarren commented 4 years ago

When building REST APIs that follow the HAL/Hateoas spec it is common for metadata fields that aren't directly attached to the resource to be prefixed with an underscore eg. _links. Currently running this example through the renderer results in the first character being capitalised (Pascal case).

_links => Links

We could cater for this either by:

  1. changing the default behaviour to preserve the first character if it's an underscore.
  2. providing a settings option to enable this preserve behaviour.

I'm leaning to number 2 to avoid breaking the current behaviour if people are relying on that. However thinking about it I can't think of a use-case where you would want the Pascal case behaviour. Either way I'm happy to make a contribution, @jozo do you have any thoughts on this?

jozo commented 4 years ago

Contribution is definitely welcomed @jamesjwarren . And I think number 1 is better option - I guess people don't want to remove leading underscore.