yada icon indicating copy to clipboard operation
yada copied to clipboard

Path parameters are not coerced

Open p-himik opened this issue 6 years ago • 4 comments

E.g. I have a path like /a/1 and I try to match it with a bidi route like ["/a/" :id]. If in the corresponding yada resource I write {:parameters {:path {:id Integer}}} it fails and the error clearly shows that it was not able to match "1" and Integer.

p-himik avatar Mar 19 '19 09:03 p-himik

{:parameters {:path Integer}}

Did you mean {:parameters {:path {:id Integer}}}? Could you provide a complete example? Even better, can you come up with a Clojure test that can be added to yada?

runejuhl avatar Mar 19 '19 09:03 runejuhl

Right, sorry - edited the description. I'll try.

p-himik avatar Mar 19 '19 09:03 p-himik

Thank you @p-himik :smile:

runejuhl avatar Mar 19 '19 09:03 runejuhl

While just reading yada's code, accidentally stumbled upon the root cause: https://github.com/juxt/yada/blob/master/src/yada/parameters.clj#L66 query-coercions has s/Int but doesn't have Integer. To be honest, I'm not sure if it needs to be there at all, given that number literals in Clojure are Long/BigInt by default. But if not fixing, then probably a warning/error or a documentation notice.

p-himik avatar Apr 06 '19 06:04 p-himik