Fork me on GitHub
#ring-swagger
<
2017-09-28
>
daveliepmann11:09:34

: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"]

sammikko12:09:57

@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

daveliepmann12:09:56

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

sammikko12:09:17

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

daveliepmann12:09:04

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.

juhoteperi12:09:35

@daveliepmann Ring-swagger has existing schemas for Files

juhoteperi12:09:55

ring.swagger.upload/TimeFileUpload

daveliepmann12:09:06

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

sammikko19:09:23

@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