Todayβs episode of ClojureScript Podcast is with @miikka about Reitit β check it out https://clojurescriptpodcast.com
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?
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.
Yes, it's also explain in this part of this vid: https://youtu.be/ChUzrcB9L1c?t=551
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 invocationLooks 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 {}
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: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)}}]