aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-07-08 17:32:48 +0200
committerKim Alvefur <zash@zash.se>2022-07-08 17:32:48 +0200
commit89359b70dc0446cdda15da19173f460504bafc3d (patch)
treece589d446940d9c5ac2ce5cf9a342c6031a94054 /spec
parente700edc50f3bd7f05d45bb4410396178811f3561 (diff)
downloadprosody-89359b70dc0446cdda15da19173f460504bafc3d.tar.gz
prosody-89359b70dc0446cdda15da19173f460504bafc3d.zip
util.datamapper: Improve handling of schemas with non-obvious "type"
The JSON Schema specification says that schemas are objects or booleans, and that the 'type' property is optional and can be an array. This module previously allowed bare type names as schemas and did not really handle booleans. It now handles missing 'type' properties and boolean 'true' as a schema. Objects and arrays are guessed based on the presence of 'properties' or 'items' field.
Diffstat (limited to 'spec')
-rw-r--r--spec/util_datamapper_spec.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/spec/util_datamapper_spec.lua b/spec/util_datamapper_spec.lua
index 3b0ae87e..51ccf127 100644
--- a/spec/util_datamapper_spec.lua
+++ b/spec/util_datamapper_spec.lua
@@ -25,7 +25,7 @@ describe("util.datamapper", function()
from = attr();
type = attr();
id = attr();
- body = "string";
+ body = true; -- should be assumed to be a string
lang = {type = "string"; xml = {attribute = true; prefix = "xml"}};
delay = {
type = "object";
@@ -56,7 +56,8 @@ describe("util.datamapper", function()
xml = {namespace = "urn:xmpp:reactions:0"; name = "reactions"};
properties = {
to = {type = "string"; xml = {attribute = true; name = "id"}};
- reactions = {type = "array"; items = {type = "string"; xml = {name = "reaction"}}};
+ -- should be assumed to be array since it has 'items'
+ reactions = { items = { xml = { name = "reaction" } } };
};
};
stanza_ids = {
@@ -190,7 +191,8 @@ describe("util.datamapper", function()
version = {
type = "object";
xml = {name = "query"; namespace = "jabber:iq:version"};
- properties = {name = "string"; version = "string"; os = "string"};
+ -- properties should be assumed to be strings
+ properties = {name = true; version = {}; os = {}};
};
};
};