api7 / jsonschema

Pure Lua JSON schema validator for Lua/LuaJIT
https://www.apiseven.com/
Apache License 2.0
119 stars 28 forks source link

Fails to generate valdiator with $id property #67

Open piotrp opened 2 years ago

piotrp commented 2 years ago

Example, worked in 0.8:

jsonschema.generate_validator({
  type = "object",
  properties = {
    ["$id"] = { type = "string" }
  }
})

Now (0.9.5) fails with:

.../lib/openresty/luajit/share/lua/5.1/jsonschema/store.lua:199: attempt to concatenate field '$id' (a table value)

stack traceback:
        .../lib/openresty/luajit/share/lua/5.1/jsonschema/store.lua:199: in function 'walk'
        .../lib/openresty/luajit/share/lua/5.1/jsonschema/store.lua:235: in function 'walk'
        .../lib/openresty/luajit/share/lua/5.1/jsonschema/store.lua:240: in function 'new'
        /usr/lib/openresty/luajit/share/lua/5.1/jsonschema.lua:323: in function 'codectx'
        /usr/lib/openresty/luajit/share/lua/5.1/jsonschema.lua:1139: in function 'generate_main_validator_ctx'
        /usr/lib/openresty/luajit/share/lua/5.1/jsonschema.lua:1163: in function 'generate_validator'

I found this when checking validation against draft 7 metaschema from http://json-schema.org/draft-07/schema

membphis commented 2 years ago

This is a todo feature, currently not supported.

welcome PR .