iodide-project / iodide

Literate scientific computing and communication for the web
Mozilla Public License 2.0
1.49k stars 143 forks source link

make the django rest api return camelCase #2132

Open hamilton opened 5 years ago

hamilton commented 5 years ago

As we begin to rely on polling for certain notebook features (revisions, files, file sources, etc.) we will be using the django REST api more. By default, the API returns data in snake case. Ideally it would return camel case so we can bring some stylistic harmony to the redux store.

wlach commented 5 years ago

It looks like django rest framework camel case plugin would do the trick here:

https://www.django-rest-framework.org/api-guide/renderers/#camelcase-json

bcolloran commented 5 years ago

fwiw: there's a tradeoff between stylistic harmony and the ability to search-all-files for a variable name and have all the instances of that name show up in your results. I don't work on both the front and back ends as much as you guys do, so i'll defer to your preferences on that, but i use search-all-files to great effect constantly when i'm digging around our code, so having these strings be different in the client and server code is a consideration that would be on my mind

wlach commented 5 years ago

fwiw: there's a tradeoff between stylistic harmony and the ability to search-all-files for a variable name and have all the instances of that name show up in your results. I don't work on both the front and back ends as much as you guys do, so i'll defer to your preferences on that, but i use search-all-files to great effect constantly when i'm digging around our code, so having these strings be different in the client and server code is a consideration that would be on my mind

Yeah, I definitely do this too, but it's in my experience relatively rare for me to want to search both server and client definitions simultaneously. It's usually one or the other (actually I usually restrict my search to either src or server depending on what I'm looking for).

Another argument for using camel case is that it's usually what people expect when using a server API in general. Currently the only non-iodide usage of the API is the redash "open in iodide" extension, but I would expect many many more applications to start using it in the future.

bcolloran commented 5 years ago

@wlach did you fix this with https://github.com/iodide-project/iodide/pull/2289 ?