🐛 Fix uuid encode/decode on schema

This commit is contained in:
Andrey Antukh 2025-04-11 12:39:11 +02:00
parent 38e5c161e7
commit a4145a30f5

View file

@ -395,9 +395,15 @@
(defn parse-uuid (defn parse-uuid
[s] [s]
(if (string? s) (try
(some->> (re-matches uuid-rx s) uuid/uuid) (uuid/parse s)
s)) (catch #?(:clj Exception :cljs :default) _cause
s)))
(defn encode-uuid
[v]
(when (uuid? v)
(str v)))
(register! (register!
{:type ::uuid {:type ::uuid
@ -409,8 +415,8 @@
:gen/gen (sg/uuid) :gen/gen (sg/uuid)
:decode/string parse-uuid :decode/string parse-uuid
:decode/json parse-uuid :decode/json parse-uuid
:encode/string str :encode/string encode-uuid
:encode/json str :encode/json encode-uuid
::oapi/type "string" ::oapi/type "string"
::oapi/format "uuid"}}) ::oapi/format "uuid"}})