🎉 Add proper schema encoding/decoding mechanism

this allows almost all api operations to success usin application/json
encoding with the exception of the update-file, which we need to
approach a bit differently;

the reason update-file is different, is because the operations vector
is right now defined without the context of shape type, so we are just
unable to properly parse the value to correct type using the schema
decoding mechanism
This commit is contained in:
Andrey Antukh 2024-08-16 12:07:53 +02:00
parent 0db1eed87f
commit cacee40d11
50 changed files with 1290 additions and 843 deletions

View file

@ -115,7 +115,7 @@
(def ^:private render-objects-decoder
(sm/lazy-decoder schema:render-objects
sm/default-transformer))
sm/string-transformer))
(def ^:private render-objects-validator
(sm/lazy-validator schema:render-objects))
@ -236,7 +236,7 @@
(def ^:private render-components-decoder
(sm/lazy-decoder schema:render-components
sm/default-transformer))
sm/string-transformer))
(def ^:private render-components-validator
(sm/lazy-validator schema:render-components))

View file

@ -79,7 +79,7 @@
[f {:keys [schema validators]}]
(fn [& args]
(let [state (apply f args)
cleaned (sm/decode schema (:data state))
cleaned (sm/decode schema (:data state) sm/string-transformer)
valid? (sm/validate schema cleaned)
errors (when-not valid?
(collect-schema-errors schema validators state))]

View file

@ -129,6 +129,8 @@
:else
(transform-prop-key k))))
;; FIXME: REPEATED from app.common.json
(defn map->obj
"A simplified version of clj->js with focus on performance"
([x] (map->obj x identity))