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

Not working with https://github.com/vbabiy/djangorestframework-camel-case #80

Open
amitv9493 opened this issue Jul 28, 2024 · 1 comment

Comments

@amitv9493
Copy link

I am using the https://github.com/vbabiy/djangorestframework-camel-case in order to format the response to camel case. The problem is when there is any Error is raised, the fields are rendered as snake case. Here are the example:

When resource is successfully created I get this response:

{
    "createdAt": "2024-07-28T13:58:50.062565Z",
    "updatedAt": "2024-07-28T13:58:50.062691Z",
    "clientName": "string",
    "clientPhone": "string",
    "clientEmail": "[email protected]",
    "taskTime": "2024-07-28T13:58:13.054000Z",
    "notes": "string",
    "paymentAmount": 20,
    "paymentMethod": "ONLINE",{
    "type": "validation_error",
    "errors": [
        {
            "code": "required",
            "detail": "This field is required.",
            "attr": "client_name"
        }
    ]
}
    "isCompleted": true,
    "jobType": "APPLY",
    "jobDeadline": "2024-07-28T13:58:13.054000Z",
    "applyDeadline": "2024-07-28T13:58:13.054000Z",
    "brokerage": "MY-BROKERAGE",
    "showClientPhoneNumber": true,
    "accessInformation": "string",
    "createdBy": null,
    "property": 1,
    "assignedTo": null
}

But when an error is raised, I am getting attr rendered in snake case due to which api developers are getting too much confused :

{
    "type": "validation_error",
    "errors": [
        {
            "code": "required",
            "detail": "This field is required.",
            "attr": "client_name"
        }
    ]
}
@ghazi-git
Copy link
Owner

Hi @amitv9493, djangorestframework-camel-case is not supported out of the box, still check #59, it might be helpful to solve your issue

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