Fork me on GitHub
#ring-swagger
<
2017-11-01
>
qr416:11:05

Hey, I got a few issues with compojure-api: 1. I get a weird Error regarding Swagger:

Assert failed: :swagger is deprecated with 2.0.0, use [:info :public] instead
   (nil? swagger)
even though i do not have a swagger key in my config map. 2. I get a
com.fasterxml.jackson.core.JsonGenerationException: Cannot JSON encode object of class: class myproject.my_resource$fn__16
if a body does not conform to the Schema described in :body property.

qr416:11:31

Argh, I solved the second issue. I used s/conditional in the body scheme. 😞

ikitommi17:11:51

@vitali.henne do you have a line number of that assert error?

qr417:11:58

@ikitommi:

meta.clj:  645  compojure.api.meta/restructure
                  meta.clj:  617  compojure.api.meta/restructure
                  core.clj:   60  compojure.api.core/GET

ikitommi17:11:43

@vitali.henne There is some custom restructuring that is emitting :swagger data into you route meta. Have you used custom restructuring? If not, what does your GET look like in whole?

ikitommi17:11:56

e.g. If you evaluate your route at a repl, you should see something like this:

(GET "/kikka" []
  :swagger {:a 1}
  "kikka")
#compojure.api.routes.Route
{:childs nil
 :handler #<Fn@1e7ce1fa compojure.core/wrap_route_matches[fn]>
 :info {:public {:a 1}}
 :method :get
 :path "/kikka"}

qr418:11:32

I had a custom built middleware which emitted (of which I was unaware) the :swagger. Thank you very much for your help 🙂