diff --git a/spec/util_jsonschema_spec.lua b/spec/util_jsonschema_spec.lua index cd4bcadd8..c33d95f6e 100644 --- a/spec/util_jsonschema_spec.lua +++ b/spec/util_jsonschema_spec.lua @@ -31,7 +31,10 @@ local skip = { ["patternProperties.json"] = "NYI", ["properties.json:1:2"] = "NYI", ["properties.json:1:3"] = "NYI", + ["propertyNames.json:1:1"] = "NYI", ["ref.json:0:3"] = "util.jsonpointer recursive issue?", + ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", + ["ref.json:6:1"] = "NYI", ["ref.json:11"] = "NYI", ["ref.json:12:1"] = "FIXME", ["ref.json:13"] = "NYI", @@ -41,28 +44,26 @@ local skip = { ["ref.json:17"] = "NYI", ["ref.json:18"] = "NYI", ["ref.json:19"] = "NYI", + ["ref.json:20"] = "NYI", + ["ref.json:25"] = "NYI", ["ref.json:26"] = "NYI", ["ref.json:27"] = "NYI", ["ref.json:28"] = "NYI", - ["ref.json:3:2"] = "FIXME investigate, util.jsonpath issue?", - ["required.json:4"] = "JavaScript specific and distinguishing objects from arrays", - ["ref.json:6:1"] = "NYI", - ["ref.json:20"] = "NYI", - ["ref.json:25"] = "NYI", ["ref.json:29"] = "NYI", ["ref.json:30"] = "NYI", ["ref.json:31"] = "NYI", ["ref.json:32"] = "NYI", ["not.json:6"] = "NYI", - ["refRemote.json"] = "DEFINITELY NYI", ["required.json:0:2"] = "distinguishing objects from arrays", + ["required.json:4"] = "JavaScript specific and distinguishing objects from arrays", + ["not.json:8:0"] = "NYI", + ["refRemote.json"] = "DEFINITELY NYI", ["type.json:0:1"] = "1.0 is not an integer!", ["type.json:3:4"] = "distinguishing objects from arrays", ["type.json:3:6"] = "null is weird", ["type.json:4:3"] = "distinguishing objects from arrays", ["type.json:4:6"] = "null is weird", ["type.json:9:4"] = "null is weird", - ["type.json:9:6"] = "null is weird", ["unevaluatedItems.json"] = "NYI", ["unevaluatedProperties.json"] = "NYI", ["uniqueItems.json:0:10"] = "deepcompare", diff --git a/teal-src/prosody/util/jsonschema.tl b/teal-src/prosody/util/jsonschema.tl index 1cc2314fb..390594c6e 100644 --- a/teal-src/prosody/util/jsonschema.tl +++ b/teal-src/prosody/util/jsonschema.tl @@ -315,7 +315,7 @@ local function validate (schema : schema_t, data : any, root : json_schema_objec end end - if schema["not"] then + if schema["not"] ~= nil then if validate(schema["not"], data, root, sloc.."/not", iloc, errs) then table.insert(errs, mkerr(sloc.."/not", iloc, "did match subschema")) return false, errs; @@ -324,14 +324,14 @@ local function validate (schema : schema_t, data : any, root : json_schema_objec if schema["if"] ~= nil then if validate(schema["if"], data, root, sloc.."/if", iloc, errs) then - if schema["then"] then + if schema["then"] ~= nil then if not validate(schema["then"], data, root, sloc.."/then", iloc, errs) then table.insert(errs, mkerr(sloc.."/then", iloc, "did not match subschema")) return false, errs; end end else - if schema["else"] then + if schema["else"] ~= nil then if not validate(schema["else"], data, root, sloc.."/else", iloc, errs) then table.insert(errs, mkerr(sloc.."/else", iloc, "did not match subschema")) return false, errs; diff --git a/util/jsonschema.lua b/util/jsonschema.lua index d7a2f9c93..a7acb8667 100644 --- a/util/jsonschema.lua +++ b/util/jsonschema.lua @@ -188,7 +188,7 @@ local function validate(schema, data, root, sloc, iloc, errs) end end - if schema["not"] then + if schema["not"] ~= nil then if validate(schema["not"], data, root, sloc .. "/not", iloc, errs) then table.insert(errs, mkerr(sloc .. "/not", iloc, "did match subschema")) return false, errs @@ -197,14 +197,14 @@ local function validate(schema, data, root, sloc, iloc, errs) if schema["if"] ~= nil then if validate(schema["if"], data, root, sloc .. "/if", iloc, errs) then - if schema["then"] then + if schema["then"] ~= nil then if not validate(schema["then"], data, root, sloc .. "/then", iloc, errs) then table.insert(errs, mkerr(sloc .. "/then", iloc, "did not match subschema")) return false, errs end end else - if schema["else"] then + if schema["else"] ~= nil then if not validate(schema["else"], data, root, sloc .. "/else", iloc, errs) then table.insert(errs, mkerr(sloc .. "/else", iloc, "did not match subschema")) return false, errs