pboettch / json-schema-validator

JSON schema validator for JSON for Modern C++
Other
466 stars 134 forks source link

Validating the gltf2.0 schema fails #136

Closed elmajime closed 3 years ago

elmajime commented 3 years ago

I have to create a validator for our automated tests regarding the gltf2.0 files that we generate. But the library tells me there is a problem with the provided schema:

[json.exception.type_error.302] type must be number, but is boolean

At first I thought I did something wrong but then I tried using the json-validate app and got the same error. Could it be that the gltf2.0 schemas really have a problem?

The displayed error isn't very usefull but after some work I managed to get something more: at least one subschema has failed, but all of them are required to validate - unresolved or freed schema-reference /glTFChildOfRootProperty.schema.json #

This appears multiple times after the first error is shown.

schema.zip

pboettch commented 3 years ago

Fun, I like to debug new things like this, let me check. Maybe standard-version problem?

pboettch commented 3 years ago

Could you provide an instance which fails?

elmajime commented 3 years ago

For me it fails at the "set_root_schema". You can use any gltf file I suppose, but can't provide you with any as they are internal... Oh and the entry file of the schema is glTF.schema.json

pboettch commented 3 years ago

I checked, the schema is draft4. This library works with the draft7-spec.

One thing I found was the "exclusiveMinimum": true in camera.orthographic.schema.json. In draft-7 exclusiveMinimum expects a number. See here: https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#page-9

I think if you correct these, the schema will work.

elmajime commented 3 years ago

Ok great thank you for your help ! I guess I'm heading to the gltf repo now to notice them about this ^^"

pboettch commented 3 years ago

Feel free to link their issue here.

elmajime commented 3 years ago

Ok after scrolling through the issues on their github it seems they might not change this for a while. I suppose you are not planning to integrate the draft 04 support you had in version one anytime soon right? I'll have to switch to version 1 I suppose.

pboettch commented 3 years ago

Don't use version 1. It requires and old nlohmann. Can you just change the schema? remove min/maximum and replace it with exclusiveMin/Maximum.

elmajime commented 3 years ago

These are not my schemas, they are Khronos Schemas (the ones that created OpenGL) and the Gltf format (based on Json) is widely used for 3D content so we have to stick to the specification. I'm abandonning for now, maybe will look at your code some times and see if it could handle draft-04 somehow with minor evolutions. Thanks a lot !