Fork me on GitHub
#ring-swagger
<
2020-02-03
>
slipset10:02:04

Oh, and another one:

slipset10:02:00

(s/def ::bar string?)
(s/def ::qix string?)

(s/def ::foo (s/keys :req-un [::bar]))
(s/def ::baz (s/keys :req-un [::qix]))

(spec-tools/merge ::foo ::bar)

;; works fine

(def bar ::bar)

(spec-tools/merge ::foo bar)

;; throws

slipset10:02:57

(defmethod parse-form 'spec-tools.core/merge [_ form]
  (let [type-priority #({:map        1
                         :multi-spec 0} (:type %) 0)]

    (apply impl/deep-merge (->> (rest form)
                                (map parse-spec)
                                (sort-by type-priority)))))

slipset10:02:12

makes the problem go away, but I’m not sure if it actually fixes the problem.

slipset10:02:31

I’d be happy to submit a PR once i’ve played with it a bit.

4
slipset10:02:57

This is just a switcheroo on the map lookup with a default value.

ikitommi10:02:08

btw, would anyone be intersted in having a #malli coercion module for c-api? #reitit has that.

slipset10:02:37

I’ll create an issue for now so I don’t forget to make the PR

slipset16:02:19

st/coerce doesn’t seem to work across s/*

ikitommi19:02:36

I think none of the regex specs have coercion impl.

slipset20:02:27

Seems like it from the comments 😞

slipset20:02:34

Something like

slipset20:02:02

(defmethod parse/parse-form 'clojure.spec.alpha/* [_ form]
  {:type [:vector]
   ::parse/item (-> form second parse/parse-spec-with-spec-ref)})
Seems to work. I’m just trying stuff and seeing if it works.

slipset20:02:36

Oh, but there is more to it than that. (s/* ) returns a map, so it seems as if parse-spec needs to be taught about it.