Fork me on GitHub
#ring-swagger
<
2017-03-30
>
borkdude11:03:48

Is it possible to add more general documentation about your API somewhere in swagger-ui?

borkdude11:03:14

Not belonging to one specific endpoint. E.g. I made an optional key in every endpoint that enables to transform the response before it’s sent to the client.

ikitommi11:03:22

yes, there is the description, which takes markdown.

ikitommi11:03:56

[:swagger :data :info :description] that is.

borkdude11:03:08

I’ll try it, thanks

peyotz13:03:42

I’m trying to add some middleware to my api, and I’m not quite sure how to do it…this is what I have so far

(api/api
       {:middleware [#(friend/wrap-authorize % #{"user"})]
        :swagger
        {:ui "/api-docs"
         :spec "/swagger.json"
         :data {:info {:title "Cenx Topology API"
                       :description "REST API for topology data"}
                :tags [....]}}}

       (api/context "/api" []
                    (api/context "..." []
                                 ...)))

peyotz13:03:00

I’m adding a :middleware key to the api opts, is that not correct?

peyotz13:03:33

ok I added that middleware to each individual route, and it seems to have worked

peyotz13:03:50

I’ll do a bit more digging to see if I can apply middleware to all the routes defined in the API

peyotz13:03:09

ok so this seems to be working

(api/middleware
    [#(friend/wrap-authorize % #{"user"})]
…

ikitommi14:03:25

@peyotz the :middleware api option is in the 1.2.0-alph4, where middleware is also removed. The docs are partially out of phase I guess.

peyotz14:03:25

ah ok, that’s good to know

ikitommi14:03:30

[[friend/wrap-authorize #{"user"}]] works too, the duct data syntax for mw.

peyotz14:03:44

oh, that’s nicer..thanks 🙂