ring-swagger

ring-swagger & compojure-api
daveliepmann 2017-09-28T11:47:34.000194Z

:return java.io.File produces "ERROR don't know how to convert class java.io.File into a Swagger Schema. Check out ring-swagger docs for details. java.lang.IllegalArgumentException: don't know how to convert class java.io.File into a Swagger Schema. Check out ring-swagger docs for details." I'm on [metosin/compojure-api "2.0.0-alpha5"]

sammikko 2017-09-28T12:08:57.000255Z

@daveliepmann you can probably extend JsonSchema protocol to convert your type (File) into JSON schema, check out https://github.com/metosin/ring-swagger#schema-to-swagger-json-schema-conversion

daveliepmann 2017-09-28T12:18:56.000239Z

@sammikko so something like :return (defmethod ring.swagger.json-schema/convert-class java.io.File [_ _] {:type "file"}) ?

sammikko 2017-09-28T12:22:17.000045Z

yes, im not sure what the corresponding json schema type is though 🙂

daveliepmann 2017-09-28T12:27:04.000027Z

Me neither—I think Swagger expects "file". Regardless, I'm still getting an error when running the Swagger UI, which makes me suspect something is borked in how I set it up.

juhoteperi 2017-09-28T12:29:35.000168Z

@daveliepmann Ring-swagger has existing schemas for Files

juhoteperi 2017-09-28T12:29:55.000258Z

ring.swagger.upload/TimeFileUpload

daveliepmann 2017-09-28T12:34:06.000236Z

@juhoteperi that's for uploads and therefore is defined to have stuff like a tempfile key that I believe makes it not appropriate for a response schema, which is what I need.

juhoteperi 2017-09-28T12:46:59.000154Z

Oh right

sammikko 2017-09-28T19:17:23.000198Z

@daveliepmann sorry, didnt read your example right.. just leave java.io.File under :response and you have to call (defmethod ring.swagger.json-schema/convert-class java.io.File [ ] {:type "file"}) only once before ring swagger stuff gets called.. it kind of registers your extension of the multimethod

1