Skip to content

Commit

Permalink
add support for $defs instead of definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
rpatters1 committed Nov 26, 2024
1 parent fbd72de commit 5bcd66c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/json-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,11 +1386,18 @@ std::shared_ptr<schema> schema::make(json &schema,
schema.erase(attr);
}

attr = schema.find("definitions");
if (attr != schema.end()) {
for (auto &def : attr.value().items())
schema::make(def.value(), root, {"definitions", def.key()}, uris);
schema.erase(attr);
auto findDefinitions = [&](const std::string &defs) -> bool {
attr = schema.find(defs);
if (attr != schema.end()) {
for (auto &def : attr.value().items())
schema::make(def.value(), root, {defs, def.key()}, uris);
schema.erase(attr);
return true;
}
return false;
};
if (!findDefinitions("definitions")) {
findDefinitions("$defs");
}

attr = schema.find("$ref");
Expand Down

0 comments on commit 5bcd66c

Please sign in to comment.