ring-swagger & compojure-api
staypufd 2017-11-23T05:31:07.000105Z

I’m trying to find out what special formatting I can use in the :summary blocks for API methods in Compojure-API? So far I haven’t stumbled across it in the docs…

juhoteperi 2017-11-23T05:49:26.000067Z

@staypufd Swagger-UI supports markdown formatting

ikitommi 2017-11-23T07:01:16.000037Z

@petr.mensik I haven’t used wrap-reload is a long time, but the reloaded-workflow instead where the reset reloads all the routes, so not sure how that works. One thing that could help is to use the subroutes as Vars if they are in different namespaces.

, with this, the route reference is re-evaluated each time there is a request. Not sure if that works. I recommend the reloaded workflow.

ikitommi 2017-11-23T07:02:39.000052Z

another thing, I would use :middleware option of the api instead of route-middleware. e.g.

   {:middleware [[wrap-resource resource-root]]}

ikitommi 2017-11-23T12:50:07.000102Z

[metosin/compojure-api "2.0.0-alpha14"] is out, with a updated version of Muuntaja: the :allow-empty-input? didn’t work properly causing random nil on input.

ikitommi 2017-11-23T12:51:11.000267Z

Not sure should we wait for clojure.spec to ship before putting the 2.0.0 out. Has taken 1.5+ year so far…

ikitommi 2017-11-23T12:52:07.000408Z

I think Rich is doing something functional with spec, so everything might break. would like to wait until we see what it looks like before launching.

ikitommi 2017-11-23T12:53:54.000170Z

maybe some depreceations (`defapi` & defroutes), proper docs and then… wait.

petr.mensik 2017-11-23T19:07:03.000065Z

Thank you, middleware key worked for me.

ikitommi 2017-11-23T19:26:32.000072Z

@petr.mensik yes you can, and should. There is a good example project with all-the-stuff at https://github.com/yogthos/memory-hole

scknkkrer 2017-11-23T20:31:36.000128Z

Hi guys.

scknkkrer 2017-11-23T20:43:09.000060Z

silly question but, I just wanted to get params from my json request client.

scknkkrer 2017-11-23T20:43:34.000032Z

Is there any example ?

scknkkrer 2017-11-23T20:44:47.000057Z

I use ring-json library and I just want to get :json-params value.

ikitommi 2017-11-23T20:47:39.000056Z

hi! the parameters are found in :body-params regardless of the encoding.

scknkkrer 2017-11-23T20:48:30.000142Z

I wrap my handler with json wrappers provided by ring library. But there is no value in body-params.

ikitommi 2017-11-23T20:48:38.000068Z

api mounts muuntaja.middleware/wrap-formats, which does json, edn and transit, so you don’t need the ring-json on top of it.

ikitommi 2017-11-23T20:50:17.000198Z

hmm… simplest echo api would be: (api (fn [request] {:status 200, :body (:body-parameters request)}))

ikitommi 2017-11-23T20:50:49.000141Z

“send whatever, return the body-paramters in a http 200 response”

scknkkrer 2017-11-23T20:51:43.000031Z

Can I get, my request map ?

scknkkrer 2017-11-23T20:51:49.000094Z

Just for debugging.

ikitommi 2017-11-23T20:53:08.000018Z

request map from compojure?

ikitommi 2017-11-23T20:53:10.000073Z


ikitommi 2017-11-23T20:53:38.000091Z

(POST "/echo" request
  (println request)
  (ok {:hello "world"}))

ikitommi 2017-11-23T20:53:56.000047Z


ikitommi 2017-11-23T20:54:32.000103Z

(POST "/echo" []
  (fn [request]
    (println request)
    (ok {:thanks-to "james"})))

scknkkrer 2017-11-23T20:56:13.000073Z


scknkkrer 2017-11-23T20:56:19.000131Z

Sorry for the silly question again.

ikitommi 2017-11-23T20:58:01.000192Z

np, not a silly q. there is a nice routing guide in Luminus: http://www.luminusweb.net/docs/routes.md

scknkkrer 2017-11-23T22:39:56.000021Z

Thanks again. 🐣