Diff

spec/util_datamapper_spec.lua @ 12133:11060c8919b6

util.datamapper: Add support for $ref pointers Allows reuse of repetitive definitions in schemas.
author Kim Alvefur <zash@zash.se>
date Wed, 29 Dec 2021 17:57:09 +0100
parent 11494:284c822d4c3d
child 12134:912614c4bf3e
line wrap: on
line diff
--- a/spec/util_datamapper_spec.lua	Wed Dec 29 16:57:35 2021 +0100
+++ b/spec/util_datamapper_spec.lua	Wed Dec 29 17:57:09 2021 +0100
@@ -15,8 +15,9 @@
 	setup(function()
 
 		-- a convenience function for simple attributes, there's a few of them
-		local function attr() return {type = "string"; xml = {attribute = true}} end
+		local function attr() return {["$ref"]="#/$defs/attr"} end
 		s = {
+			["$defs"] = { attr = { type = "string"; xml = { attribute = true } } };
 			type = "object";
 			xml = {name = "message"; namespace = "jabber:client"};
 			properties = {
@@ -111,6 +112,7 @@
 		};
 
 		disco_schema = {
+			["$defs"] = { attr = { type = "string"; xml = { attribute = true } } };
 			type = "object";
 			xml = {
 				name = "iq";