ring-swagger

ring-swagger & compojure-api
2018-02-20T02:42:58.000007Z

it seems like nested destructuring doesn’t work with the context macro from compojure.api.sweet

2018-02-20T02:43:10.000219Z

is that by design or should i file a bug

2018-02-20T02:43:16.000059Z

for example:

2018-02-20T02:44:15.000154Z

; this works
(context "" {:keys [identity]}
...)

; this doesn't work
(context "" {{{:keys [user-id]} :user} :identity}
...)

ikitommi 2018-02-20T07:02:35.000078Z

@nickmbailey does that work with vanilla Compojure? if it does, it’s a bug in the compojure-syntax parser at compojure.api.meta. I guess I haven’t used that deep with routes.

ikitommi 2018-02-20T07:05:13.000210Z

@jimenezsaezjoseantoni older versions of ring-swagger emitted those, should be fix in 0.24.3: https://github.com/metosin/ring-swagger/blob/1e932951d115706e7724cedd032d623e2d849905/CHANGELOG.md#0243-24102017

logistark 2018-02-20T08:53:47.000305Z

Thanks, i will take a look!🙂

2018-02-20T14:54:37.000434Z

@ikitommi well compojure api generates a compiler error and compojure doesn’t so i’d guess a bug in compojure.api.meta then

2018-02-20T14:54:56.000386Z

repl session:

dev=> (require '[compojure.core :refer [GET]])
nil
dev=> (require '[compojure.api.sweet :refer [context]])
nil
dev=> (GET "/" {:keys [identity]}
 #_=>   (println identity))
#<Fn@2747f665 compojure.core/wrap_route_matches[fn]>
dev=> (GET "/" {{{:keys [user-id]} :user} :identity}
 #_=>   (println user-id))
#<Fn@11623d80 compojure.core/wrap_route_matches[fn]>
dev=> (context "" {:keys [identity]}
 #_=>   (println identity))
#function[clojure.core/identity]
#compojure.api.routes.Route
{:childs [nil]
 :handler #<Fn@3e251ea0 compojure.core/make_context[handler]>
 :info {}
 :method nil
 :path ""}
dev=> (context "" {{{:keys [user-id]} :user} :identity}
 #_=>   (println user-id))

             java.lang.RuntimeException: Unable to resolve symbol: user-id in this context
clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: Unable to resolve symbol: user-id in this context, compiling:(/private/var/folders/47/631bq0cs75q8gk7jf0r8c30h0000gn/T/form-init2896469317029772128.clj:2:3)

2018-02-20T15:08:24.000772Z

makes sense

2018-02-20T15:08:32.000267Z

i can file a bug

2018-02-20T15:08:52.000178Z

and possibly have some time to look at a fix later this week

ikitommi 2018-02-20T15:09:09.000143Z

that would be great!

ikitommi 2018-02-20T21:53:24.000491Z

I’m under 🌴 until 12.3. Juho & Miikka will help with any possible stuff there is.

slipset 2018-02-20T22:27:43.000588Z

Have a great vacation!