beacon-v2 icon indicating copy to clipboard operation
beacon-v2 copied to clipboard

Validation errors with `oneOf` elements

Open mrueda opened this issue 3 years ago • 1 comments

This is part of an ongoing discussion that I've been having with @mbaudis.

When we validate this example data for individuals we get these errors:

Row 1:
/diseases/0/ageOfOnset: oneOf rules 0, 1 match.
/measures/0/observationMoment: oneOf rules 0, 1 match.

Meaning that we have a match in two of the options, when we should have a match in exactly one.

The error has been reproduced with other JSON schema validators (e.g., Python's jsonchema).

Here I am showing a simplified version of what is happening: Example schema:

 {
  type                 : 'object',
    properties           : {},
    additionalProperties : {
        oneOf : [
            { oneLevel  : { type : 'string' } },
            {
                properties :
                  { twoLevel : { type : 'string' } } 
            }
        ],
    },
}

Input: { bar : 'beacon' }

The example can be validated at https://www.jsonschemavalidator.net

It's likely that this issue happens in other places of the beacon v2 models as well, as I recall having validation problems with quantity object when I was transforming CINECA's synthetic data for the RI.

If this is actually an error/problem (is it???) one possible (ad hoc) solution could be changing oneOf for anyOf, but it sounds very drastic to me.

mrueda avatar Sep 28 '22 12:09 mrueda

anyOf can easily generate similar or worse issues, particularly if the different cases have overlapping property names, see #56.

gsfk avatar Feb 06 '23 18:02 gsfk