ring-swagger

ring-swagger & compojure-api
psalaberria002 2017-10-12T10:33:58.000249Z

hi! I have upgraded from 1.x to 2.x and I am having issues with getting the body in some routes. It’s related to https://github.com/weavejester/compojure/wiki/Common-Problems . Before I had (middleware [[wrap-restful-params {:formats [:json :edn]}]] ...) so all routes got the body. I tried (route-middleware [[wrap-restful-params {:formats [:json :edn]}]] ...) since middleware was deprecated, but that did not do the trick.

psalaberria002 2017-10-12T10:37:22.000214Z

what’s the new middleware I should use?

psalaberria002 2017-10-12T10:47:12.000013Z

my setup is same as https://github.com/metosin/compojure-api/issues/206

ikitommi 2017-10-12T11:16:19.000012Z

@psalaberria002 2.x will use Muuntaja instead of ring-middleware-format, it’s 10x faster but with different config. There is a guide in Muuntaja how to set it up: https://github.com/metosin/muuntaja/wiki/Configuration.

ikitommi 2017-10-12T11:17:35.000103Z

If you want it with defaults, adding muuntaja.middleware/wrap-format should do it.

ikitommi 2017-10-12T11:17:50.000105Z

I could update the wiki actually.

ikitommi 2017-10-12T11:17:52.000205Z

Just a sec.

psalaberria002 2017-10-12T11:21:17.000023Z

awesome! that’s what I was looking for

psalaberria002 2017-10-12T11:31:54.000376Z

I will give it a try.

psalaberria002 2017-10-12T11:38:16.000231Z

still not working

psalaberria002 2017-10-12T11:38:21.000225Z

am I missing something?

psalaberria002 2017-10-12T11:39:38.000184Z

ooo I see now

ikitommi 2017-10-12T11:39:40.000015Z

Hmm…

psalaberria002 2017-10-12T11:39:51.000169Z

in your docs you have a different way of declaring the middleware

ikitommi 2017-10-12T11:41:08.000250Z

I can’t recall what the route-middleware does, but it’s just a vanilla ring middleware, so (wrap-format (routes route1 route2)) kind of thing should work I think.

psalaberria002 2017-10-12T11:41:57.000143Z

it worked that way

psalaberria002 2017-10-12T11:41:59.000370Z

great!

psalaberria002 2017-10-12T11:42:03.000404Z

thanks for the help

ikitommi 2017-10-12T11:42:13.000255Z

and, you don’t have to say the :formats in the apis, if you have defined before those. Doesn’t matter but there can be many Muuntaja mws in the pipeline, first matching does the thing, others are no-op.

👍 1
ikitommi 2017-10-12T11:42:55.000369Z

np, great to hear you got it working. someone needs to rewrite the docs before 2.0.0 can be pushed out…

ikitommi 2017-10-12T11:43:58.000050Z

btw, you have :format {:formats [:json :edn]} under the :swagger? I believe it doesn’t mean anything there.

psalaberria002 2017-10-12T11:44:16.000314Z

I was just playing with it

psalaberria002 2017-10-12T11:44:20.000216Z

I will remove it

ikitommi 2017-10-12T11:44:25.000089Z

ok, cool 🙂

bmabey 2017-10-12T15:29:07.000538Z

I'm trying to figure out how to coerce my response specs in compoure-api, could someone take a look and point me in the right direction? https://stackoverflow.com/questions/46702269/compojure-api-spec-coercion-on-response-body

ikitommi 2017-10-12T20:11:23.000052Z

@bmabey hi, answered on the SO.

bmabey 2017-10-13T17:19:12.000294Z

the gist was very helpful thanks!

bmabey 2017-10-12T20:42:22.000586Z

Thanks! I had a follow-up question that I added there to keep the conversation in one place.

bmabey 2017-10-12T20:43:14.000323Z

BTW, thanks for spec-tools and compojure-api!