Fork me on GitHub

Today’s episode of ClojureScript Podcast is with @miikka about Reitit — check it out

🎉 8

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 is klicked, nothing happens. Is this a reitit thing, or am I looking in the wrong direction?


Okay, the solution is actually in the docs for anyone looking: :ignore-anchor-click? is customizable and takes a function.

Michaël Salihi07:04:22

Yes, it's also explain in this part of this vid:

👍 2
Ronny Løvtangen20:04:22

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: So far we have only added authorization header to routes:

  ["/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

Ronny Løvtangen20:04:59

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 {}

Ronny Løvtangen21:04:51

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: What got me on the right track was this example, although it has empty :securityDefinitions:

Ronny Løvtangen21:04:11

: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)}}]

👍 3