JSON Schema validation: difference between Windows and Ubuntu versions

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
mbreebhotmailcom
Posts: 5
Joined: Wed Mar 10, 2021 2:48 am

JSON Schema validation: difference between Windows and Ubuntu versions

Post by mbreebhotmailcom » Thu Jul 22, 2021 1:37 pm

Hi,

I noticed that validating a JSON instance to a JSON Schema file gives different results on XML Editor 23.0 on Windows vs XML Editor 23.1 on Ubuntu.

It seems to boil down to the usage of the oneOf construct. The Windows version understands this (and gives errors when necessary), but the Ubuntu version seems to ignore it (and allows everything when it shouldn't).

Is this based on a setting somewhere in the Ubuntu version?

Thanks,

Matthijs

florin_nica
Site Admin
Posts: 3
Joined: Wed Sep 09, 2020 3:17 pm

Re: JSON Schema validation: difference between Windows and Ubuntu versions

Post by florin_nica » Fri Jul 23, 2021 11:24 am

Hi Matthijs,

Thanks for your report. I don't think that the validation problems are related to the operating system. I also tested out the usage of the "oneOf" construct on both Oxygen XML Editor 23.0 and 23.1, but I couldn't figure out where the problem is. Maybe you could send us the files you used for validation, in order to reproduce the problem.

Regards,
Florin

mbreebhotmailcom
Posts: 5
Joined: Wed Mar 10, 2021 2:48 am

Re: JSON Schema validation: difference between Windows and Ubuntu versions

Post by mbreebhotmailcom » Mon Jul 26, 2021 1:48 am

Hi Florin,

I've looked into it a bit more and it seems to be a slightly different problem. It is more a hit-or-miss thing, where Ubuntu is more often miss but Windows version is not working 100% all the time either.

It is about this kind of JSON Schema construct (copied from the a schema that is > 350 lines):

Code: Select all

 "imageFeedback": {
            "type": "array",
            "items": {
                "type": "object",
                "oneOf": [
                    {
                        "properties": {
                            "timestamp": {"type": "string"},
                            "actor": {"$ref": "#/definitions/actor"},
                            "remark": {"type": "string"},
                            "type": {
                                "type": "string",
                                "const": "articleprocessor"
                            },
                            "problems": {"$ref": "#/definitions/problems"},
                            "corrections": {"$ref": "#/definitions/corrections"}
                        },
                        "additionalProperties": false
                    },
                    {
                        "properties": {
                            "timestamp": {"type": "string"},
                            "actor": {"$ref": "#/definitions/actor"},
                            "remark": {"type": "string"},
                            "type": {
                                "type": "string",
                                "const": "artworkprocessor"
                            },
                            "improvementOpportunities": {"$ref": "#/definitions/improvementOpportunities"},
                            "resultcodes": {"$ref": "#/definitions/resultcodes"}
                        },
                        "additionalProperties": false
                    }
                ]
            }
        },
The type value decides which properties are allowed. Same trick with oneOf happens in one of the children (actor).

In principle, Oxygen understands this and will point out errors if the type value is wrong or if keys are used that are not listed with the type. This is extremely useful when working with a JSON Schema like this.

However, it seems to crash or otherwise fail randomly. Then all validation is off. This happens in both versions of Oxygen but Windows seems to hold up a bit better. It could be the size of our schema (350 lines) combined with the size of the instances (>2000 lines) but that doesn't seems too excessive.

Sorry that I cannot be more specific.

florin_nica
Site Admin
Posts: 3
Joined: Wed Sep 09, 2020 3:17 pm

Re: JSON Schema validation: difference between Windows and Ubuntu versions

Post by florin_nica » Mon Jul 26, 2021 6:27 pm

Hi Matthijs,

Thanks for sending us this sample schema. I tried (on Windows) to validate multiple instances using this schema, and the validation seemed to work every time. Indeed, the schema is not oversized, but, as you mentioned, in combination with large instances, the validator might get confused. We will do further investigation into this, but I can't come up with a solution at this point.

Regards,
Florin

Post Reply