ring-swagger

ring-swagger & compojure-api
ikitommi 2017-11-16T07:11:43.000102Z

@j0ni currently, the response coercion middleware is added to the nearest to the handler and all own mw are applied after it (in the response pipeline). Usually one would like to see the coerced response in the mws. But clearly there are cases for the opposite. Do you have ideas how to fix this… elegantly?

ikitommi 2017-11-16T07:12:42.000142Z

@slipset 2.0.0-SNAPSHOT should have the context+coercion fixed. The :coercion was only applied to children of context, not to itself.

ikitommi 2017-11-16T07:13:39.000131Z

the pred-thing. How are you getting it? Does it apper with the latest version(s)?

slipset 2017-11-16T07:30:24.000133Z

@ikitommi I’ll find a minimal report for the prod thing once I’m back at work. It might have cropped up while having a predicate that was coll-of smthng. I figured it was related to the first bug you fixed for me (the one where the pred was serialized to json (which didn’t work for anonymous fns)). I seem to remember you doing a str to fix that, and that sort of rhymes with what I see.

slipset 2017-11-16T11:23:24.000119Z

Sure did 🙂 https://github.com/metosin/compojure-api/pull/356

👍 1
arttuka 2017-11-16T13:20:02.000339Z

hi, just noticed that clojure.spec.alpha/merge breaks JSON conforming in Compojure-API / spec-tools. With this body spec:

(s/def ::kw1 st/keyword?)
(s/def ::kw2 st/keyword?)
(s/def ::body (s/merge (s/keys :req-un [::kw1])
                       (s/keys :req-un [::kw2])))
and this request body:
{
  "kw1": "kw1",
  "kw2": "kw2"
}
in the conformed request body, the value of :kw1 is the string "kw1"and the value of :kw2 is the keyword :kw2:
{:kw1 "kw1", :kw2 :kw2}

arttuka 2017-11-16T13:20:27.000346Z

not sure if this is a known bug so i thought i’d first throw it here before filing an issue on github

ikitommi 2017-11-16T13:23:20.000132Z

@arttuka haven’t seen. And it’s in spec-tools. Hoping for a PR…

slipset 2017-11-16T13:27:12.000418Z

@ikitommi If you could give me some pointers to where to start wrt to the two issues I filed yesterday, I’d be more than happy to try a couple of PRs

slipset 2017-11-16T13:27:16.000243Z

https://github.com/metosin/compojure-api/issues/354

slipset 2017-11-16T13:27:18.000459Z

and

slipset 2017-11-16T13:27:38.000042Z

https://github.com/metosin/spec-tools/issues/89

ikitommi 2017-11-16T13:33:56.000449Z

sure! * https://github.com/metosin/compojure-api/blob/master/src/compojure/api/meta.clj#L435 <--- extract schema from the letk notation. * https://github.com/metosin/spec-tools/blob/master/src/spec_tools/visitor.cljc#L9-L22 <--- spec walker, should fail-fast

j0ni 2017-11-16T14:03:41.000586Z

@ikitommi hrm, tricky - initially I was thinking something like {:middleware {:inner [[wrap-my-middleware]] :outer [[wrap-the-regular-mw]]}} but I'm not sure that applying transformations in that sequence to requests is anything but confusing. So maybe it would be better to have, so maybe it shouldn't be thought of as middleware

j0ni 2017-11-16T14:08:34.000266Z

I can't think what I'd call the key though... something that points to the response-only nature of the transformation

ikitommi 2017-11-16T14:36:21.000184Z

@j0ni one option would be to disable The response coercion and manually add the response-coercion mw into right place on the chain

j0ni 2017-11-16T14:38:35.000717Z

that sounds good - so long as the request-coercion remains in last place regardless

petr.mensik 2017-11-16T20:51:37.000146Z

May I ask how to turn off response validation for Schema? Ideally just for certain routes and not globally (although global config would be fine as well)