drf-standardized-errors icon indicating copy to clipboard operation
drf-standardized-errors copied to clipboard

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

Open amitv9493 opened this issue 1 year ago • 1 comments

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"
        }
    ]
}

amitv9493 avatar Jul 28 '24 14:07 amitv9493

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

ghazi-git avatar Jul 29 '24 20:07 ghazi-git