atlassian / atlassian/better-ajv-errors

Feature: Option to include data path in CLI output

Open
#46 10 comments 0 reactions 1 assignee Claimed by @torifat View on GitHub
feature request
Dominant language
JavaScript
Stars
245
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Data paths are great when working with big, repeating or complex responses, but at the moment these paths are not included in the CLI output. It would also be very useful if you don't have the `indent` option set.

I'd like to have an option to enable data path output in the CLI mode. It might look something like.

```javascript
const output = betterAjvErrors(schema, response.body, ajv.errors, {
indent: 2,
dataPath: true,
});
console.log(output);
```

```
Error: FORMAT should match format "date-time"

5 | "foo": "624050509",
6 | "bar": "04",
> 7 | "baz": "not-a-date-time",
| ^^^^^^^^^^^^^^^^^ 👈🏽 format should match format "date-time"
8 | "lorum": "@",
9 | "ipsum": "some string",
10 | "razz": 100797.51,

@ /a/long/path/9/with/2/big/21/arrays/baz
```

And sure, the example above is a really extreme example, and if your API looks like this you have bigger problems. But these things exist in the wild, so I'd like to at least be able to test them with some ease. This feature would contribute to this.

I'm willing to implement this myself if someone can tell me where to start :)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.