Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation errors with oneOf elements #49

Open
mrueda opened this issue Sep 28, 2022 · 1 comment
Open

Validation errors with oneOf elements #49

mrueda opened this issue Sep 28, 2022 · 1 comment

Comments

@mrueda
Copy link
Collaborator

mrueda commented Sep 28, 2022

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.

@gsfk
Copy link
Collaborator

gsfk commented Feb 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants