reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
jacekschae 2021-04-28T07:02:52.177900Z

Today’s episode of ClojureScript Podcast is with @miikka about Reitit β€” check it out https://clojurescriptpodcast.com

πŸŽ‰ 3
wegi 2021-04-28T07:40:20.180Z

Hey, I use reitit for the frontend and have use-fragments set to false . But now jump links do not seem to work, i.e. when a link http://example.com#any-id is klicked, nothing happens. Is this a reitit thing, or am I looking in the wrong direction?

wegi 2021-04-28T07:44:33.180100Z

Okay, the solution is actually in the docs for anyone looking: https://cljdoc.org/d/metosin/reitit/0.5.12/api/reitit.frontend.easy :ignore-anchor-click? is customizable and takes a function.

2021-04-28T07:48:22.180400Z

Yes, it's also explain in this part of this vid: https://youtu.be/ChUzrcB9L1c?t=551

πŸ‘ 1
2021-04-28T20:37:22.185900Z

Hi. Is it possible to configure authorizations when using reitit-swagger? What I am trying to accomplish, is a Authorize-button in upper right corner where I can provide a token on a global level. Example of Swagger docs with such button: https://api.prodreg.no/restapi/v1/doc3/#/ So far we have only added authorization header to routes:

(ring/router
...
  ["/client" {:parameters {:header [:map schema/AccessToken]}
              ...
(def token-pattern #"^Bearer (.+)$")

(def AccessToken [:authorization
                  {:description "SSO access token"
                   :json-schema/example "Bearer eyJhbGciOiJS..."}
                  [:re token-pattern]])
But then I need to provide token for each invocation

2021-04-28T20:47:59.188Z

Looks like I’m onto something:

{:get {:no-doc true
       :swagger {:info {:title "Title"
                        :description "Desc"}
                 :securityDefinitions {}}
       :handler (swagger/create-swagger-handler)}}
After adding :securityDefinitions {} I got the Authorize button Now I just need to figure out what to put inside {}

2021-04-28T21:33:51.190900Z

Finally got it working:

:securityDefinitions {:bearerAuth {:type "apiKey" :name "Authorization" :in "header"}}
In addition, routes must be configured to use this securityDefinition:
["/client" {:swagger {:security [{:bearerAuth []}]}}
   ...
Documentation: https://swagger.io/docs/specification/2-0/authentication/ What got me on the right track was this example, although it has empty :securityDefinitions: https://github.com/metosin/ring-swagger/blob/master/test/ring/swagger/swagger2_test.clj

2021-04-28T21:39:11.192Z

:security [{:bearerAuth []}]
can be set alongside securityDefinitions as well:
["/swagger.json" {:get {:no-doc true
                        :swagger {:info {:title "Title"
                                         :description "Desc"}
                                  :security [{:bearerAuth []}]
                                  :securityDefinitions {:bearerAuth {:type "apiKey" :name "Authorization" :in "header"}}}
                        :handler (swagger/create-swagger-handler)}}]

πŸ‘ 1