Fork me on GitHub
#yada
<
2016-03-02
>
malcolmsparks07:03:31

@ericfode after thinking about this, I feel logging each request (and result, starus code, etc.) Is something that yada should offer to do as core. There are plans to do this and provide a console too.

aspra09:03:34

@malcolmsparks: Not sure what I had in mind, I somehow thought it was handled as a special property or something. And then maybe the swagger version was derived from there. Content negotiation will do. Thanks a lot for your quick answer!

imre15:03:24

Hi @malcolmsparks I'm trying to upgrade to the latest yada and I seem to be bumping into an exception:

imre15:03:31

{:type java.lang.UnsupportedOperationException
   :message "nth not supported on this type: PersistentArrayMap"
   :at [clojure.lang.RT nthFrom "RT.java" 933]}]
 :trace
 [[clojure.lang.RT nthFrom "RT.java" 933]
  [clojure.lang.RT nth "RT.java" 883]
  [bidi.bidi$route_seq invoke "bidi.cljc" 386]
  [bidi.bidi$route_seq invoke "bidi.cljc" 390]
  [yada.swagger$swagger_spec doInvoke "swagger.clj" 89]
  [clojure.lang.RestFn invoke "RestFn.java" 425]
  [yada.swagger$swaggered doInvoke "swagger.clj" 172]

imre15:03:01

(yada/swaggered
                              {:info     {:title   "API"
                                                 :version "0.1"}
                                      :basePath api-path}
                              (yada/yada "asdf"))

imre15:03:11

with something like this

imre15:03:13

has something changed recently around swagger integration?

imre15:03:44

even (yada/swaggered {} "asdf") is throwing the same

malcolmsparks15:03:34

@imre Args have been switched. It's so the resource comes first to smooth use of ->

imre15:03:14

that should be simple to fix

imre15:03:48

it worked, thank you!

iwillig15:03:56

hey, i am using yada and am getting a 406 for a request that seems correct, or almost correct.

iwillig15:03:01

my resource look like this

iwillig15:03:07

(defn get-all [connection]
  (-> {:methods {:get {:response (fn [_] (mapv maps/map-site (sm/hyrdate-sites connection)))}}
       :access-control
       {:allow-origin ""}
       :produces [{:media-type "application/transit+json"
                   :charset "utf-8"}]
       :consumes [{:media-type "application/transit+json"
                   :charset "utf-8"}]}
      ;;(merge core/produces-transit core/consumes-transit)
      (yada/resource)))

iwillig15:03:15

and my request looks like

iwillig15:03:32

curl -i '' -H 'Accept: application/transit+json; charset=utf-8' -H 'Referer: ' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' —compressed

iwillig15:03:41

i am guessing that is has something to do with the charset or the encoding but i am not sure what is miss-aligned

iwillig15:03:16

however this request works

iwillig15:03:19

curl -i '' -H 'Accept: application/transit+json' -H 'Referer: ' -H 'Connection: keep-alive' -H 'Cache-Control: max-age=0' —compressed

iwillig15:03:34

so if i drop the charset from the Accept header Yada returns a 200

ericfode18:03:10

I need some help decrypting this stack trace

malcolmsparks18:03:58

@iwillig charsets are only applicable for text/* media types. Try dropping the charset altogether from the produces, consumes and accept header. application/json charset is non-negotiable, and only determined between utf-8, utf-16 and utf-32 by sniffing the initial byte order mark. This is outside the scope of http and by extension yada.

malcolmsparks18:03:46

application/json;charset=utf-8 is not a recognisable mimetype as per its iana registration

malcolmsparks18:03:26

@ericfode it's the error from aleph when bidi doesn't match anything

malcolmsparks18:03:42

Good tip is ending with a backstop of [true (yada nil)] giving you a 404

malcolmsparks18:03:25

@iwillig np, hope you get it working

ericfode21:03:22

It was missing due to improper vhosts configuration… Not sure where I would have put something to catch that since the backstop still misses it...

malcolmsparks23:03:39

Ah ok. Vhosts is new. Probably needs some more thought