-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Description
I found a bug when using boolean fields in my JSON Schema. My partial JSON Schema which I use to detect the error was the following:
...
"bool_param":{
"oneOf":[{
"type":"boolean"
},{
"enum":["external"]
}],
"default":true,
"description":"Description of bool_param. Set as 'external' if the value is not yet known and thus will be set externally at runtime (only once) depending on e.g. the outcome of a previous action or the outcome of another module."
},
...When setting it to true or false, I got the following error when validating the schema:
lua: /usr/local/share/lua/5.1/jsonschema.lua:701: bad argument #4 to 'sformat' (string expected, got boolean)
stack traceback:
[C]: in function 'sformat'
/usr/local/share/lua/5.1/jsonschema.lua:701: in function 'generate_validator'
/usr/local/share/lua/5.1/jsonschema.lua:173: in function 'validator'
/usr/local/share/lua/5.1/jsonschema.lua:678: in function 'generate_validator'
/usr/local/share/lua/5.1/jsonschema.lua:173: in function 'validator'
/usr/local/share/lua/5.1/jsonschema.lua:1184: in function 'generate_main_validator_ctx'
/usr/local/share/lua/5.1/jsonschema.lua:1201: in function 'generate_validator'
./task_requirements.lua:501: in function 'load_json_table'
example.lua:35: in main chunk
[C]: ?The bug was (apparently) easily fixed by changing line 701 of the jsonschema.lua from:
ctx:stmt(sformat(' %s[%s] = %s', ctx:param(1), str_filter(prop), default))to
ctx:stmt(sformat(' %s[%s] = %s', tostring(ctx:param(1)), str_filter(prop), tostring(default)))I guess this happens because lua does not convert booleans to strings automatically.
Metadata
Metadata
Assignees
Labels
No labels