ring-swagger & compojure-api
petr.mensik 2018-10-23T13:32:32.000100Z

How come that this handler is returning body as ByteArrayInputStream instead of plain JSON?

(defroutes users
  (context "/bizzi-test/users" []
    (GET "/" []
      :summary "Gets all users"
      (ok {:message "Get all users"}))))

(def handler
              (api {:swagger
                    {:ui "/docs"
                     :spec "/swagger.json"
                     :data {:info {:title "Bizziapp REST API documentation"
                                   :description "Documentation which describes all REST endpoints provided by Bizziapp"}
                            :produces ["application/json"]
                            :consumes ["application/json"]}}}
                   (undocumented (route/not-found (not-found {:message "This route had not been found"})))))
I tested it with a ring-mock (handler (mock/request :get "/users")) . Thanks for answer 🙂

ikitommi 2018-10-23T20:18:53.000100Z

@petr.mensik c-api uses Muuntaja under the hoods, which return InputStreams by default (can be changed to return byte-arrays or lazy streams instead). You can slurp the body to get the string value.

petr.mensik 2018-10-23T20:25:05.000100Z

@ikitommi thanks a lot 🙂 Btw is there an easy way how to generate swagger.json file out of the API docs described with Schema (let's from the code above) ? I am going through ring-swagger and I cannot find any obvious answers there 😕