ring-swagger & compojure-api
slipset 2020-02-03T10:35:04.003800Z

Oh, and another one:

slipset 2020-02-03T10:36:06.004200Z

https://github.com/metosin/spec-tools/blob/master/src/spec_tools/parse.cljc#L236 throws when spec is defined through a symbol

slipset 2020-02-03T10:40:00.004700Z

(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

ikitommi 2020-02-03T10:40:17.004900Z

PR welcome

slipset 2020-02-03T10:40:57.006Z

(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)))))

slipset 2020-02-03T10:41:12.006600Z

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

slipset 2020-02-03T10:41:31.007300Z

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

slipset 2020-02-03T10:41:57.008100Z

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

ikitommi 2020-02-03T10:42:08.008400Z

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

slipset 2020-02-03T10:47:37.009100Z

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

slipset 2020-02-03T16:12:19.009600Z

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

ikitommi 2020-02-03T19:56:36.011700Z

I think none of the regex specs have coercion impl.

slipset 2020-02-03T20:02:27.012Z

Seems like it from the comments 😞

slipset 2020-02-03T20:06:34.012300Z

Something like

slipset 2020-02-03T20:07:02.013Z

(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.

slipset 2020-02-03T20:32:36.013900Z

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.