Closed miniHive closed 1 year ago
Cannot reproduce:
$ json-schema-eval
enter data instance, followed by ^D:
{ "a": 0, "b": 0, "c": 0 }
^D
enter schema, followed by ^D:
{
"type": "object",
"properties": {
"a": {"type": "integer"} ,
"b": false
},
"unevaluatedProperties" : false
}
^D
{
"errors" : [
{
"error" : "property not permitted",
"instanceLocation" : "/b",
"keywordLocation" : "/properties/b"
},
{
"error" : "not all properties are valid",
"instanceLocation" : "",
"keywordLocation" : "/properties"
},
{
"error" : "additional property not permitted",
"instanceLocation" : "/c",
"keywordLocation" : "/unevaluatedProperties"
},
{
"error" : "not all additional properties are valid",
"instanceLocation" : "",
"keywordLocation" : "/unevaluatedProperties"
}
],
"valid" : false
}
Can you provide the actual data you are passing, not json-encoded? Also see https://metacpan.org/pod/JSON::Schema::Modern#Types.
We wrote a code wrapper to be able to read the data from file: https://github.com/sdbs-uni-p/ke_validator/blob/main/runScript.pl
Did we maybe garble the input in doing so?
I can reproduce your issue with your test script.
I replaced your use of JSON::Parse in your test script with:
use Cpanel::JSON::XS;
use Path::Tiny;
...
my $instance_data = decode_json(path($instance_path)->slurp_raw);
my $schema_data = decode_json(path($schema_path)->slurp_raw);
...
..and the problem goes away. I would suggest not using JSON::Parse, as it is clearly not decoding the json data correctly. You might want to report to the maintainers of JSON::Parse that they are inflating integers as PVNV, rather than IV. Cpanel::JSON::XS (or the wrapper module, JSON::MaybeXS) is the most robust and reliable JSON decoder in perl.
Thank you so much, it now works wonderfully.
Experimenting with the validator, I run into a exception "ambigous type":
Data:
{ "a": 0, "b": 0, "c": 0 }
Schema:
Output (flag "basic"):