Fork me on GitHub
#ring-swagger
<
2017-10-18
>
ikitommi07:10:20

one could ask (methods multimethod) to verify that when app is created, all things are bound. But still, configuration via multimethods is imperative, opposed of purely functional transformation of a single (admittedly, huge) configuration map. I think data is the way to go at the lowest level anyway, there could be helpers on top. Let’s draft something and see how they look like

slipset07:10:09

totally agree on the approach of huge config-map with helpers on top.

slipset08:10:40

@ikitommi hate to bother you more, but there is one thing I cannot figure out:

slipset08:10:18

Whenever I POST an invalid date here, I get an error from Muuntaja.

slipset08:10:35

I'm quite certain that this is on the request coercion.

slipset08:10:19

I would have expected this to give me a spec error.

slipset08:10:38

I can reproduce this on outbound as well:

ikitommi08:10:00

I'll check that out after lunch.

slipset08:10:14

appreciated.

slipset08:10:46

Enjoy the mustamakkara 🙂

ikitommi11:10:35

@slipset if the spec-coercion fails, the result fails to serialize. Root cause is that we are returning the Spec :problems over the wire and the :pred can be anything - here it’s (partial instance? DateTime) which fails to serialize. Wrapping the :pred to str should make the errors correct. Here, it would be:

{:spec "(spec-tools.core/spec {:spec (clojure.spec.alpha/keys :req-un [:compojure.api.coercion.erik/id :compojure.api.coercion.erik/name :compojure.api.coercion.erik/date]), :type :map, :keys #{:date :name :id}, :keys/req #{:date :name :id}})",
 :problems [{:path ["date"],
             :pred "(clojure.core/partial clojure.core/instance? org.joda.time.DateTime)",
             :val "lol",
             :via ["compojure.api.coercion.erik/id-name-date" "compojure.api.coercion.erik/date"],
             :in ["date"],
             :reason "FAIL"}],
 :type "compojure.api.exception/response-validation",
 :coercion "spec",
 :value {:id 1, :name "foo", :date "lol"},
 :in ["response" "body"]}

ikitommi11:10:52

will push a fix soon.

slipset11:10:12

I'm just happy it wasn't my fault 🙂

ikitommi17:10:29

@slipset japanese 😉 fix now in [metosin/compojure-api "2.0.0-alpha9"]. Also, keyword specs are not memoized in coercion, should remove odd behavior if specs are redefined in dev.

slipset18:10:37

Thanks alot. Will check out tomorrow.