Skip to content

Commit ffbc040

Browse files
committed
make -identify-ref-schema private fully fully baked
1 parent 96b1532 commit ffbc040

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/malli/core.cljc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,7 +1928,11 @@
19281928

19291929
;; returns an identifier for the :ref schema in the context of its dynamic scope.
19301930
;; useful for detecting cycles.
1931-
(defn -identify-ref-schema [schema]
1931+
;; copied to malli.generator
1932+
(defn- -identify-ref-schema [schema]
1933+
;; TODO mr/-schemas doesn't seem reliable, making defn private for now.
1934+
;; a better approach would be to accumulate a 'seen' map from name => ?schema
1935+
;; and if we expand the same name again with the same seen map, it's a cycle.
19321936
{:scope (-> schema -options -registry mr/-schemas)
19331937
:name (-ref schema)})
19341938

src/malli/generator.cljc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,13 @@
295295
;; ;; (1)
296296
;; [:or [:ref ::a] [:ref ::b]]]]
297297

298+
;; copied to malli.core
299+
(defn- -identify-ref-schema [schema]
300+
{:scope (-> schema m/-options m/-registry mr/-schemas)
301+
:name (m/-ref schema)})
302+
298303
(defn -ref-gen [schema options]
299-
(let [ref-id (m/-identify-ref-schema schema)]
304+
(let [ref-id (-identify-ref-schema schema)]
300305
(or (force (get-in options [::rec-gen ref-id]))
301306
(let [scalar-ref-gen (delay (-never-gen options))
302307
dschema (m/deref schema)]

0 commit comments

Comments
 (0)