From 3640cd5d5e6f0a3ddce4db9815a3e38888807c03 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Wed, 24 Jan 2024 08:33:10 +0200 Subject: [PATCH] fix #997 --- src/malli/core.cljc | 2 +- test/malli/core_test.cljc | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/malli/core.cljc b/src/malli/core.cljc index 4771f901d..0d5e260ba 100644 --- a/src/malli/core.cljc +++ b/src/malli/core.cljc @@ -2318,7 +2318,7 @@ maybe-set-ref (fn [s r] (if (and ref-key r) (-update-properties s assoc ref-key r) s))] (-> (walk schema (fn [schema _ children _] (cond (= :ref (type schema)) schema - (-ref-schema? schema) (-> children (first) (maybe-set-ref (-ref schema))) + (-ref-schema? schema) (maybe-set-ref (deref (-set-children schema children)) (-ref schema)) :else (-set-children schema children))) {::walk-schema-refs true}) (deref-all))))) diff --git a/test/malli/core_test.cljc b/test/malli/core_test.cljc index 2a6db5015..e440bb8e2 100644 --- a/test/malli/core_test.cljc +++ b/test/malli/core_test.cljc @@ -3069,4 +3069,23 @@ [:address [:map {:id ::address} [:street :string] [:lonlat {:optional true} [:tuple :double :double]]]]] - (m/form (m/deref-recursive schema {::m/ref-key :id})))))) + (m/form (m/deref-recursive schema {::m/ref-key :id})))) + (testing "util schemas" + (let [registry (merge (m/default-schemas) (mu/schemas))] + (is (= [:map [:x :int] [:y :int]] + (m/form (m/deref-recursive + [:merge + [:map [:x :int]] + [:map [:y :int]]] + {:registry registry})))) + (is (= [:map {:id ::xymap} + [::x [:int {:id ::x}]] + [::y [:int {:id ::y}]]] + (m/form (m/deref-recursive + [:schema {:registry {::x :int + ::y :int + ::xmap [:map ::x] + ::ymap [:map ::y] + ::xymap [:merge ::xmap ::ymap]}} + ::xymap] + {:registry registry, ::m/ref-key :id}))))))))