cont : remove dead code

This commit is contained in:
Alde Rojas
2026-09-12 13:23:12 -05:00
parent c8c25a0022
commit 55d9cf0722
3 changed files with 1 additions and 33 deletions
+1 -5
View File
@@ -104,7 +104,7 @@ class common_schema_builder {
if (ref.compare(0, 2, "#/") != 0) {
fail(path, "unsupported $ref " + ref + ", only references into the same document are supported");
}
if (doc_.refs.find(ref) == doc_.refs.end() && refs_.find(ref) == refs_.end()) {
if (refs_.find(ref) == refs_.end()) {
// reserve the key first, so that a cycle back to this $ref stops here
refs_[ref] = nullptr;
refs_[ref] = build_node(resolve_ref(ref, path), ref);
@@ -343,10 +343,6 @@ common_schema_document common_schema_from_json(const common_json & schema) {
return doc;
}
common_schema_ptr common_schema_from_json(const common_json & schema, common_schema_document & doc) {
return common_schema_builder(schema, doc).build();
}
static common_schema::value_type json_type(const common_json & value) {
if (value.is_null()) {
return common_schema::TYPE_NULL;
-5
View File
@@ -196,8 +196,3 @@ using common_schema_document_ptr = std::shared_ptr<const common_schema_document>
// Throws std::runtime_error when the schema falls outside the supported subset.
common_schema_document common_schema_from_json(const common_json & schema);
// Builds a schema that belongs to a document built earlier, e.g. one property of it.
// A $ref it cannot resolve on its own is looked up in doc.refs, the targets it resolves itself are added there.
// doc is unchanged when the schema is rejected.
common_schema_ptr common_schema_from_json(const common_json & schema, common_schema_document & doc);
-23
View File
@@ -367,29 +367,6 @@ static void test_ref(testing & t) {
t.assert_true("target", r.target == doc.refs.at("#/$defs/t").get());
as<common_schema_null>(t, r.target, "target");
});
t.test("a schema parsed into a document shares its refs", [](testing & t) {
auto doc = parse(R"({"properties": {"a": {"$ref": "#/$defs/t"}}, "$defs": {"t": {"type": "boolean"}}})");
auto node = common_schema_from_json(common_json::parse(R"({"items": {"$ref": "#/$defs/t"}})"), doc);
const auto & a = as<common_schema_array>(t, node.get(), "node");
const auto & r = as<common_schema_ref>(t, a.items.get(), "items");
t.assert_true("shared target", r.target == doc.refs.at("#/$defs/t").get());
t.assert_equal("refs", (size_t) 1, doc.refs.size());
auto added = common_schema_from_json(common_json::parse(R"({"$ref": "#/$defs/u", "$defs": {"u": {"type": "null"}}})"), doc);
as<common_schema_null>(t, as<common_schema_ref>(t, added.get(), "added").target, "target");
t.assert_equal("refs", (size_t) 2, doc.refs.size());
});
t.test("a rejected schema leaves the document unchanged", [](testing & t) {
common_schema_document doc;
try {
common_schema_from_json(common_json::parse(R"({"allOf": [{"$ref": "#/$defs/t"}, {"type": "x"}], "$defs": {"t": {"type": "null"}}})"), doc);
t.assert_true("rejected", false);
} catch (const std::runtime_error &) {
t.assert_true("no refs", doc.refs.empty());
}
});
}
static void test_may_be_string(testing & t) {