jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

problem with properties that declare an element beginning with an underscore (or a property named 'enum')

Open zeteref opened this issue 1 year ago • 0 comments

Hi,

I was testing a jsonschema that can be simplified to:

{
    "type": "object",
    "properties": {
        "_actions": { "$ref": "#/components/schemas/Actions" }
    },
    "components": {
        "schemas": {
            "Actions": {
                "type": "object"
            }
        }
    }
}

Trying to generate validator for this schema results in:

lua: ./jsonschema/store.lua:77: attempt to index field 'base' (a nil value)
stack traceback:
        ./jsonschema/store.lua:77: in function 'resolve'
        ./jsonschema.lua:167: in function 'validator'
        ./jsonschema.lua:662: in function 'generate_validator'
        ./jsonschema.lua:173: in function 'validator'
        ./jsonschema.lua:1191: in function 'generate_main_validator_ctx'
        ./jsonschema.lua:1208: in function 'generate_validator'
        validate.lua:23: in main chunk
        [C]: in ?

which is because of this if condition here: https://github.com/api7/jsonschema/blob/a55072d6f4ae65a1caafea41cffd5464e971234c/lib/jsonschema/store.lua#L231

I cannot understand what is the purpose of this condition? I can try to fix it but i'm afraid to break something else that was supposed to be fixed by it...

zeteref avatar Jan 15 '25 10:01 zeteref