Fork me on GitHub
#ring-swagger
<
2017-10-12
>
psalaberria00210:10:58

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.

psalaberria00210:10:22

what’s the new middleware I should use?

ikitommi11:10:19

@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.

ikitommi11:10:35

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

ikitommi11:10:50

I could update the wiki actually.

ikitommi11:10:52

Just a sec.

psalaberria00211:10:17

awesome! that’s what I was looking for

psalaberria00211:10:54

I will give it a try.

psalaberria00211:10:16

still not working

psalaberria00211:10:21

am I missing something?

psalaberria00211:10:51

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

ikitommi11:10:08

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.

psalaberria00211:10:57

it worked that way

psalaberria00211:10:03

thanks for the help

ikitommi11:10:13

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.

ikitommi11:10:55

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

ikitommi11:10:58

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

psalaberria00211:10:16

I was just playing with it

psalaberria00211:10:20

I will remove it

ikitommi11:10:25

ok, cool 🙂

bmabey15:10:07

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

ikitommi20:10:23

@bmabey hi, answered on the SO.

bmabey20:10:22

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

bmabey20:10:14

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

ikitommi05:10:15

both the SpecCoercion and SchemaCoercion are implemented as Records, so you can print them out to see if it look ok. There could be specs out of help verifying that the data is sound after transformations.

bmabey17:10:12

the gist was very helpful thanks!

ikitommi05:10:37

Thanks! Brilliant people contributing to the libs. I created a gist: https://gist.github.com/ikitommi/8a97080357fd7de06882ba99f0df974c