Fork me on GitHub
#ring-swagger
<
2018-05-09
>
kasuko19:05:47

Hey, I have a compojure-api app that has a lot of endpoints. Recently I have moved my token from the "Authorization" header to a "token" parameter on all request for unrelated reasons. However, now compojure-api is throwing Request validation failed exceptions on all my routes because token is a disallowed-key. The token parameter is handled by authentication middleware on ring and not by compojure-api. Is there a way to allow a parameter on all endpoints without writing it on all endpoints?

ikitommi19:05:46

@kasuko what kind of paramerer that is? extra body parameter?

kasuko20:05:58

url parameter

ikitommi20:05:41

url? you can add the parameter definition into a context too, and it gets accumulated into leafs. Something like:

(api
  (context "/api/:token" []
    :path-parameter [token :- s/Int]
    (GET "/" []
      (ok token))
    (POST "/" []
      (ok token))))

kasuko16:05:36

Oh whoops, I meant query parameter but I can modify this. Thanks for the help!