ring-swagger

ring-swagger & compojure-api
ikitommi 2018-06-20T06:58:50.000344Z

@andreasp1994 yes, just set the :formats to nil and it gets unmounted. Muuntaja btw uses the transit-clj behind the scenes.

ikitommi 2018-06-20T06:59:43.000209Z

if you use some other formatter, you need to manually define the :swagger bindings (`:produces` and :consumes).

Andreasp1994 2018-06-20T14:37:35.000695Z

@ikitommi Thank you. you are a life saver!

ikitommi 2018-06-20T15:47:41.000421Z

@dave.tenny what does the response data look like when sent from the handler?

jdt 2018-06-20T15:51:44.000106Z

The route is returning {:status 200, :headers {"Content-Type" "application/zip"}, :body #object[java.io.File 0x107ac2b6 "/tmp/de_dl_1529509838083-876870127"]}

ikitommi 2018-06-20T15:52:33.000729Z

hmm.. is that with Schema or Spec coercion enabled? (defaults to Schema)

jdt 2018-06-20T15:52:43.000461Z

This is schema coercion

jdt 2018-06-20T15:53:05.000961Z

existing production APIs I'm trying to upgrade the compojure-api tree deps on.

jdt 2018-06-20T15:55:13.000808Z

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

ikitommi 2018-06-20T15:55:34.000117Z

it’s the next alpha, cheshire -> jsonista

ikitommi 2018-06-20T15:55:45.000323Z

I’ll test the File stuff now

ikitommi 2018-06-20T15:56:40.000424Z

oh, got the same result.

jdt 2018-06-20T15:57:12.000700Z

relieved it isn't just me 😉

ikitommi 2018-06-20T15:58:05.000391Z

It should work, but I guess there is no test and it does’t.

ikitommi 2018-06-20T15:58:43.000206Z

if you remove the :return, it works. But for some reason, if thinks File should be encoded, and it can’t.

ikitommi 2018-06-20T15:59:35.000557Z

oh, it’s not coercion, it’s the encoder. I’ll try to fix.

jdt 2018-06-20T16:00:43.000767Z

Not sure what the :return comment refers to.

ikitommi 2018-06-20T16:02:44.000971Z

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.

jdt 2018-06-20T16:03:49.000064Z

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."}}

jdt 2018-06-20T16:04:16.000717Z

Multiple routes were affected, not sure about their :responses values, no doubt similar.

ikitommi 2018-06-20T16:04:43.000195Z

without the :schema File it should work already

ikitommi 2018-06-20T16:26:20.000342Z

oh, there was a test as there should be, but it was testing the wrong thing 😮

ikitommi 2018-06-20T16:29:51.000066Z

@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

👍 1
jdt 2018-06-20T16:30:17.000281Z

Thanks. Meanwhile, I confirmed that commenting out :schema File lets me work around it for today

👍 1
jdt 2018-06-20T16:30:47.000535Z

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.

jdt 2018-06-20T16:33:13.000172Z

Guess that File is actually the imported java.io.File, surprised it's even tolerated.

jdt 2018-06-20T16:33:29.000820Z

(for coercion purposes)