Fork me on GitHub
#ring-swagger
<
2017-11-23
>
staypufd05:11:07

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…

juhoteperi05:11:26

@staypufd Swagger-UI supports markdown formatting

ikitommi07:11:16

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

(api
   #'users/user-routes)
, with this, the route reference is re-evaluated each time there is a request. Not sure if that works. I recommend the reloaded workflow.

ikitommi07:11:39

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

(api
   {:middleware [[wrap-resource resource-root]]}
   ...)

ikitommi12:11:07

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

ikitommi12:11:11

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

ikitommi12:11:07

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.

ikitommi12:11:54

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

petr.mensik19:11:03

Thank you, middleware key worked for me.

ikitommi19:11:32

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

scknkkrer20:11:09

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

scknkkrer20:11:34

Is there any example ?

scknkkrer20:11:47

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

ikitommi20:11:39

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

scknkkrer20:11:30

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

ikitommi20:11:38

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

ikitommi20:11:17

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

ikitommi20:11:49

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

scknkkrer20:11:43

Can I get, my request map ?

scknkkrer20:11:49

Just for debugging.

ikitommi20:11:08

request map from compojure?

ikitommi20:11:38

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

ikitommi20:11:32

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

scknkkrer20:11:19

Sorry for the silly question again.

ikitommi20:11:01

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

scknkkrer22:11:56

Thanks again. 🐣