atlassian / atlassian/better-ajv-errors

Implement support for oneOf

Open
#72 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
245
Forks
50
PR merge metrics
No merged PRs in 30d

Description

Here is my schema:
```
{
"oneOf": [
{
"properties": {
"target": { "$ref": "#/definitions/target" }
},
"required": ["target"]
},
{
"properties": {
"sql": { "$ref": "#/definitions/sql" }
},
"required": ["sql"]
},
]
}
```

If my input has neither `sql` nor `target`, the error output is the following:

```
[{"start":{"line":1,"column":1,"offset":0},"error":" should have required property 'sql'","path":""}]
```

For the reference, here is the error output from Ajv:
```
[{"keyword":"required","dataPath":"","schemaPath":"#/oneOf/0/required","params":{"missingProperty":"target"},"message":"should have required property 'target'"},{"keyword":"required","dataPath":"","schemaPath":"#/oneOf/1/required","params":{"missingProperty":"sql"},"message":"should have required property 'sql'"},{"keyword":"oneOf","dataPath":"","schemaPath":"#/oneOf","params":{"passingSchemas":null},"message":"should match exactly one schema in oneOf"}]
```

I was expecting something like:
```
[{"start":{"line":1,"column":1,"offset":0},"error":" must have either 'sql' or 'target'","path":""}]
```

Contributor guide

No contributing guide indexed for this repository

Research direction

The issue provides a JSON Schema using oneOf and compares the current error with Ajv's output, but names no source files, tests, or entry points. Start by locating the validation-error formatting path and existing keyword handling, then reproduce the schema case. Done means unsupported oneOf errors are reported with a useful combined message such as “must have either 'sql' or 'target'”.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.