mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
🎉 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:
@@ -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))
|
||||
|
||||
@@ -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))]
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user