Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a way to camelize snakecase keys #52

Open
wujibear opened this issue Nov 28, 2022 · 3 comments
Open

Provide a way to camelize snakecase keys #52

wujibear opened this issue Nov 28, 2022 · 3 comments

Comments

@wujibear
Copy link

I'm thinking this hasn't been made yet, but is there already (or would you be open to) a way to camelize serialized attribute keys?

For my own API, I want to refer to attributes in snakecase but would rather show those attributes in camelcase when sending to the client.

@adamcrown
Copy link
Member

I left some feedback in the attached PR. This makes sense to me. Although, I wonder if it would be worth providing some out-of-the-box options too. Since I'm guessing 95% of the use cases for this would be camel case, pascal case or kebab case.

@wujibear
Copy link
Author

I had thought of just taking a symbol for :snakecase, :camelcase, etc. but then I wasn't sure it would be evaluated within rails itself rather than ruby.

I figured a lambda/proc would be more explicit and avoid potential issues with it not having string translation methods.

@wujibear
Copy link
Author

@adamcrown I've updated the PR with specs like you asked, did you have any other input for me on what you'd like to see?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants