@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?
@slipset 2.0.0-SNAPSHOT
should have the context+coercion fixed. The :coercion
was only applied to children of context, not to itself.
the pred-thing. How are you getting it? Does it apper with the latest version(s)?
@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.
Sure did 🙂 https://github.com/metosin/compojure-api/pull/356
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}
not sure if this is a known bug so i thought i’d first throw it here before filing an issue on github
@arttuka haven’t seen. And it’s in spec-tools. Hoping for a PR…
@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
and
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
@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
I can't think what I'd call the key though... something that points to the response-only nature of the transformation
@j0ni one option would be to disable The response coercion and manually add the response-coercion mw into right place on the chain
that sounds good - so long as the request-coercion remains in last place regardless
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)