add support for $defs instead of definitions.

This commit is contained in:
Robert Patterson 2024-11-26 09:27:33 -06:00 committed by Patrick Boettcher
parent fbd72de0d6
commit 1bcfdf8253

View File

@ -1386,11 +1386,18 @@ std::shared_ptr<schema> schema::make(json &schema,
schema.erase(attr); schema.erase(attr);
} }
attr = schema.find("definitions"); auto findDefinitions = [&](const std::string &defs) -> bool {
if (attr != schema.end()) { attr = schema.find(defs);
for (auto &def : attr.value().items()) if (attr != schema.end()) {
schema::make(def.value(), root, {"definitions", def.key()}, uris); for (auto &def : attr.value().items())
schema.erase(attr); 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"); attr = schema.find("$ref");