浏览代码

cleanup: dont double-add $ref

Sam Jaffe 3 周之前
父节点
当前提交
c4f4735743
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      include/jvalidate/validation_visitor.h

+ 5 - 1
include/jvalidate/validation_visitor.h

@@ -625,7 +625,11 @@ public:
     // constraints. This is enforced in the parsing of the schema, rather than
     // during validation {@see jvalidate::schema::Node::construct}.
     if (std::optional<schema::Node const *> ref = schema_->reference_schema()) {
-      rval = validate_subschema(*ref, document, "$ref");
+      if (schema_path_.empty() || schema_path_.back() != "$ref") {
+        rval = validate_subschema(*ref, document, "$ref");
+      } else {
+        rval = validate_subschema(*ref, document);
+      }
     }
 
     if (result_ && !schema_->description().empty()) {