Skip to content

Commit 1bcfdf8

Browse files
rpatters1pboettch
authored andcommitted
add support for $defs instead of definitions.
1 parent fbd72de commit 1bcfdf8

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/json-validator.cpp

+12-5
Original file line numberDiff line numberDiff line change
@@ -1386,11 +1386,18 @@ std::shared_ptr<schema> schema::make(json &schema,
13861386
schema.erase(attr);
13871387
}
13881388

1389-
attr = schema.find("definitions");
1390-
if (attr != schema.end()) {
1391-
for (auto &def : attr.value().items())
1392-
schema::make(def.value(), root, {"definitions", def.key()}, uris);
1393-
schema.erase(attr);
1389+
auto findDefinitions = [&](const std::string &defs) -> bool {
1390+
attr = schema.find(defs);
1391+
if (attr != schema.end()) {
1392+
for (auto &def : attr.value().items())
1393+
schema::make(def.value(), root, {defs, def.key()}, uris);
1394+
schema.erase(attr);
1395+
return true;
1396+
}
1397+
return false;
1398+
};
1399+
if (!findDefinitions("definitions")) {
1400+
findDefinitions("$defs");
13941401
}
13951402

13961403
attr = schema.find("$ref");

0 commit comments

Comments
 (0)