Fork me on GitHub
#ring-swagger
<
2017-02-20
>
daveliepmann15:02:02

Follow-up to my body-params question earlier: where do body-params get merged with the request? My dummied tests ran fine but I've discovered that using the Swagger UI causes a validation error.

daveliepmann15:02:54

@mrchance I use Buddy access rules, which pattern-match the request path. That could straightforwardly block unauth'd access to the entire API.

mrchance15:02:48

@daveliepmann Thanks for the reply, I ended up writing it myself since we already have all the rest of the infrastructure in place, but the solution is similar to how buddy seems to handle it

daveliepmann18:02:35

I suspect it is happening somewhere in the thicket of middleware, which I'd turned off for other reasons.

ikitommi18:02:50

@mrchance hi, about the mw order. You could set your mw inside the api. with 1.2.0-alpha3, there is the :mw key in api, e.g. (api {:mw [my-auth-verifier]} …). It would not see coercion errors as they are thrown from handlers and caught my the api-middleware, so a 400 would be returned if the data was ill.

ikitommi18:02:32

@daveliepmann to read the body-params, you should have some http-body-formatting library installed (which reads the body-stream and populates the body-params out of it). The api-middleware uses Muuntaja to do this. If you disable the api-middleware, you have to put a formatting middleware into the mw-chain yourself. There is the https://github.com/ngrunwald/ring-middleware-format (used by pre 1.2.0) and https://github.com/metosin/muuntaja (1.2.0+).

ikitommi18:02:06

your code should run smoothly with either one.