From a4145a30f52d59119b978384a74bcfe861cb760c Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 11 Apr 2025 12:39:11 +0200 Subject: [PATCH] :bug: Fix uuid encode/decode on schema --- common/src/app/common/schema.cljc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index 6d89efd89..b6f1a49c4 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -395,9 +395,15 @@ (defn parse-uuid [s] - (if (string? s) - (some->> (re-matches uuid-rx s) uuid/uuid) - s)) + (try + (uuid/parse s) + (catch #?(:clj Exception :cljs :default) _cause + s))) + +(defn encode-uuid + [v] + (when (uuid? v) + (str v))) (register! {:type ::uuid @@ -409,8 +415,8 @@ :gen/gen (sg/uuid) :decode/string parse-uuid :decode/json parse-uuid - :encode/string str - :encode/json str + :encode/string encode-uuid + :encode/json encode-uuid ::oapi/type "string" ::oapi/format "uuid"}})