Open
Description
Currently there is a struct to explain what is the reason for the denied request:
https://github.com/code0-tech/draco/blob/main/draco_body/src/rules/violation.rs
An example how that currently looks:
When I call the Adapter.
First must be a number, is currently a boolean so there will be a regex error
Second is written false, he expects a field named "second" but receives only a "secon" field. A MissingField error will be returned.
curl -X POST http://localhost:8088/add -H "Content-Type: application/json" -d '{"first": false, "secon": 5}'
Currently the response body looks like (I will continue using this pattern for debug purposes, but I think it is to complicated for a user):
{
"error": "Invalid body",
"reason": {
"error": "DataTypeRuleError",
"violation_count": 2,
"violations": [
{
"details": {
"missing_regex": "^[0-9]"
},
"explanation": "Failed to match regex pattern: '^[0-9]'",
"type": "Regex"
},
{
"details": {
"missing_key": "second"
},
"explanation": "Missing required key: 'second'",
"type": "ContainsKey"
}
]
}
}
We need a pattern to communicate to the user what went wrong (error codes, error types and so on)
Metadata
Metadata
Assignees
Labels
No labels