api7/jsonschema

why return false if input data is not empty when required set a empty array?

Opened this issue · 0 comments

I found this code in jsonschema.lua

if schema.required and #schema.required == 0 then
     -- return false if the input data is not empty
     ctx:stmt(sformat('if %s ~= 1 then', datakind))
     ctx:stmt(        '  return false, "the input data should be an empty table"')
     ctx:stmt(        'end')
end

if this, when I have a schema

{
    "type": "object",
    "properties": {
        "name": { "type": "string" }
    },
    "required": []
}

and a json object

{
  "name": "Tom"
}

such will return an err: the input data should be an empty table