Renaming response fields in transformers #209
Unanswered
guidodinello
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! First of all, thank you for this great package.
I have a question/feature discussion: Is there currently any way to rename a field in the response when using transformers?
For example, let's say we have a model with a
user_id
field, but in the API response we want it to appear asuserId
. This is easy to handle for regular model properties:However, when dealing with relationships, it becomes trickier:
Is there currently a way to keep the relationship name as relatedEntity in the model but have it appear with a different name in the API response?
Maybe something like this:
If this feature doesn't exist, I'd be happy to contribute a PR implementing it if you think it would be a valuable addition to the package.
Edit: Ive just found the
config('responder.use_camel_case_relations')
, so I guess we cant handle more custom renames.Beta Was this translation helpful? Give feedback.
All reactions