yada

borkdude 2018-02-15T13:41:50.000166Z

I might be overlooking something, but are there any docs/examples for uploading files in yada?

malcolmsparks 2018-02-15T13:43:07.000400Z

There is an upload example in the codebase. git grep upload

malcolmsparks 2018-02-15T13:43:38.000162Z

This is becoming a frequently asked question. I must add this to the docs!

malcolmsparks 2018-02-15T13:53:59.000442Z

Let me look

borkdude 2018-02-15T14:05:43.000569Z

Ah, thanks. I found an example with :consumer somewhere, but I didn’t find any docs on it

borkdude 2018-02-15T14:05:50.000265Z

I’ll try this

borkdude 2018-02-15T18:55:08.000053Z

I’m not trying a multipart/form-data approach, but I’m running into the same issues as this guy here: https://clojurians-log.clojureverse.org/yada/2017-03-13.html

borkdude 2018-02-15T18:55:52.000136Z

any working examples with file upload + some other fields would def. be helpful

borkdude 2018-02-15T19:08:41.000361Z

This kind of works:

:consumes #{"multipart/form-data"}
:parameters {:form {:skip s/Str
                         :pdf ring.swagger.upload/TempFileUpload}}

borkdude 2018-02-15T19:09:46.000482Z

but I have to include an extra dependency to make that work… https://github.com/metosin/ring-swagger/blob/master/src/ring/swagger/upload.clj#L8… I could also just copy the implementation… :-S

borkdude 2018-02-15T19:10:03.000100Z

and skip is not coerced anywhere, not sure if that should work or not

borkdude 2018-02-15T19:51:44.000639Z

Got an exception in this place: https://github.com/juxt/yada/blob/master/ext/multipart/src/yada/multipart.clj#L664 java.lang.ClassCastException: manifold.deferred.ErrorDeferred cannot be cast to clojure.lang.Associative

borkdude 2018-02-15T19:52:59.000442Z

I guess assoc-body-parameters returns an error-deferred and that’s where this error comes from: https://github.com/juxt/yada/blob/master/ext/multipart/src/yada/multipart.clj#L605

borkdude 2018-02-15T19:56:56.000334Z

lol, this was the error:

{:pdf {:content-disposition disallowed-key, :request-headers disallowed-key, :type disallowed-key, :debug disallowed-key, :headers disallowed-key, :filename missing-required-key, :content-type missing-required-key, :pieces disallowed-key, :body-offset disallowed-key}}
so it seems Schema validations on multipart form uploads is not supported or I have to adapt the ring-swagger stuff a bit

malcolmsparks 2018-02-15T20:04:36.000323Z

No. It's definitely not supported for multipart uploads

malcolmsparks 2018-02-15T20:05:05.000322Z

Not to say it couldn't be, but the code for each was written separately

borkdude 2018-02-15T20:06:31.000243Z

Is there a way I could have file uploads from the swagger API + some other fields mixed in yada currently?

borkdude 2018-02-15T20:08:41.000338Z

I could work around it and make the query parameters do the other job

2018-02-15T20:14:06.000028Z

Opened an issue for this a few months back, haven't got time to send a PR though. https://github.com/juxt/yada/issues/212