Skip to content

Commit 686408c

Browse files
authored
Merge pull request #999 from metosin/fix-997
fix #997
2 parents 8919b63 + 3640cd5 commit 686408c

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/malli/core.cljc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2318,7 +2318,7 @@
23182318
maybe-set-ref (fn [s r] (if (and ref-key r) (-update-properties s assoc ref-key r) s))]
23192319
(-> (walk schema (fn [schema _ children _]
23202320
(cond (= :ref (type schema)) schema
2321-
(-ref-schema? schema) (-> children (first) (maybe-set-ref (-ref schema)))
2321+
(-ref-schema? schema) (maybe-set-ref (deref (-set-children schema children)) (-ref schema))
23222322
:else (-set-children schema children)))
23232323
{::walk-schema-refs true})
23242324
(deref-all)))))

test/malli/core_test.cljc

+20-1
Original file line numberDiff line numberDiff line change
@@ -3069,4 +3069,23 @@
30693069
[:address [:map {:id ::address}
30703070
[:street :string]
30713071
[:lonlat {:optional true} [:tuple :double :double]]]]]
3072-
(m/form (m/deref-recursive schema {::m/ref-key :id}))))))
3072+
(m/form (m/deref-recursive schema {::m/ref-key :id}))))
3073+
(testing "util schemas"
3074+
(let [registry (merge (m/default-schemas) (mu/schemas))]
3075+
(is (= [:map [:x :int] [:y :int]]
3076+
(m/form (m/deref-recursive
3077+
[:merge
3078+
[:map [:x :int]]
3079+
[:map [:y :int]]]
3080+
{:registry registry}))))
3081+
(is (= [:map {:id ::xymap}
3082+
[::x [:int {:id ::x}]]
3083+
[::y [:int {:id ::y}]]]
3084+
(m/form (m/deref-recursive
3085+
[:schema {:registry {::x :int
3086+
::y :int
3087+
::xmap [:map ::x]
3088+
::ymap [:map ::y]
3089+
::xymap [:merge ::xmap ::ymap]}}
3090+
::xymap]
3091+
{:registry registry, ::m/ref-key :id}))))))))

0 commit comments

Comments
 (0)