@andreasp1994 yes, just set the :formats
to nil
and it gets unmounted. Muuntaja btw uses the transit-clj behind the scenes.
if you use some other formatter, you need to manually define the :swagger
bindings (`:produces` and :consumes
).
@ikitommi Thank you. you are a life saver!
@dave.tenny what does the response data look like when sent from the handler?
The route is returning {:status 200, :headers {"Content-Type" "application/zip"}, :body #object[java.io.File 0x107ac2b6 "/tmp/de_dl_1529509838083-876870127"]}
hmm.. is that with Schema or Spec coercion enabled? (defaults to Schema)
This is schema coercion
existing production APIs I'm trying to upgrade the compojure-api tree deps on.
[aside] I was sort of expecting not to see the cheshire stack trace elements, because I read that muuntaja swapped out cheshire for something else, but perhaps compojure-api 2.0.0-alpha20 doesn't use that version of muuntaja yet.
it’s the next alpha, cheshire -> jsonista
I’ll test the File stuff now
oh, got the same result.
relieved it isn't just me 😉
https://github.com/metosin/compojure-api/blob/master/src/compojure/api/coercion/schema.clj#L38-L40
It should work, but I guess there is no test and it does’t.
if you remove the :return
, it works. But for some reason, if thinks File
should be encoded, and it can’t.
oh, it’s not coercion, it’s the encoder. I’ll try to fix.
Not sure what the :return
comment refers to.
if you define an :return
or :responses
definition, it doesn’t work (due to the bug), if you don’t define the schema for the return type, it works.
This is the :responses fragment for the route
:responses {200 {:description "Content returned. (Not supported in Swagger?)"
:schema File}
204 {:description "Content is not yet available."}
403 {:description "Download access denied."}
404 {:description "Download or file does not exist."}
410 {:description "Content will not be available."}}
Multiple routes were affected, not sure about their :responses values, no doubt similar.
without the :schema File
it should work already
oh, there was a test as there should be, but it was testing the wrong thing 😮
@dave.tenny should be fixed now, will be pushed to the next release, before the summer vacations / next tue: https://github.com/metosin/compojure-api/commit/c08feedb84c5e5fe53fcc6860772acbe854ad02c
Thanks. Meanwhile, I confirmed that commenting out :schema File
lets me work around it for today
and the impact on the swagger page is minimal, the Response Class: file
wasn't super illuminating for users, unlike some of our response class elements.
Guess that File
is actually the imported java.io.File
, surprised it's even tolerated.
(for coercion purposes)