1From fa49c29942763285c51b7d2dea417d9f51e4961f Mon Sep 17 00:00:00 2001
2From: Sven Fink <sven.fink@wipotec.com>
3Date: Fri, 13 Jan 2023 09:15:42 +0100
4Subject: [PATCH 3/3] For root value, use empty pointer
5
6Upstream-Status: Backport [https://github.com/pboettch/json-schema-validator/commit/59c9d6200bf3cd54b4fc717ec1660c91eddb4d1a]
7
8Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
9---
10 src/json-validator.cpp | 8 ++++++++
11 1 file changed, 8 insertions(+)
12
13diff --git a/src/json-validator.cpp b/src/json-validator.cpp
14index 7f34553..3c73d98 100644
15--- a/src/json-validator.cpp
16+++ b/src/json-validator.cpp
17@@ -553,6 +553,9 @@ class type_schema : public schema
18 					else_->validate(ptr, instance, patch, e);
19 			}
20 		}
21+		if (instance.is_null()) {
22+			patch.add(nlohmann::json::json_pointer{}, default_value_);
23+		}
24 	}
25
26 protected:
27@@ -1134,6 +1137,11 @@ public:
28 			propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris);
29 			sch.erase(attr);
30 		}
31+
32+		attr = sch.find("default");
33+		if (attr != sch.end()) {
34+			set_default_value(*attr);
35+		}
36 	}
37 };
38
39--
402.25.1
41
42