JSON-schema error message solutions #899
Replies: 1 comment
-
Yes! That was part of the project's expected outcomes ...
I'm not sure about the best approach. I'm expecting you to propose something in your application. Think about what would be most useful. What do people actually need? What are some cases where people would want to customize the messaging and what would be the easiest way for them to do that?
I don't think we can have automated tests for clarity. That's something a human needs to evaluate. Maybe I misunderstand the question. Any general purpose testing framework will do what we need it to do, but vitest is the best testing framework in the JS/TS ecosystem right now.
Take inspiration from these tools, but I expect you to analyze the pros and cons and propose what you think it should be. That will likely mean taking ideas from both and including some ideas of your own as well. |
Beta Was this translation helpful? Give feedback.
-
As experimenting with JSON Schema validation outputs, I wanted to ask:
Would it be beneficial to support custom error message templates to allow flexibility for different use cases?
Are there any preferred testing frameworks you'd recommend for validating message clarity and accuracy?
I’ve reviewed existing tools like Atlassian's better-ajv-errors and Apideck's @apideck/better-ajv-errors, and I understand that this project aims to generate clear error messages using the standard JSON Schema output format (draft-2019-09) instead of ajv’s proprietary format.
If we use Atlassian's better-ajv-errors template :
[
{
start: { line: 6, column: 15, offset: 70 },
end: { line: 6, column: 26, offset: 81 },
error:
'/content/0/type should be equal to one of the allowed values: panel, paragraph, ...',
suggestion: 'Did you mean paragraph?',
},
];
If we use Apideck's @apideck/better-ajv-errors template :
{
"message": "'vatnum' property is not expected to be here",
"suggestion": "Did you mean property 'vatNumber'?",
"path": "{requestBody}.company",
"context": {
"errorType": "additionalProperties"
}
}
{
"message": "'type' property must be equal to one of the allowed values",
"suggestion": "Did you mean 'home'?",
"path": "{requestBody}.addresses.0.type",
"context": {
"errorType": "enum",
"allowedValues": ["home", "office", "other"]
}
}
Beta Was this translation helpful? Give feedback.
All reactions