reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
Janne Sauvala 2021-01-21T13:33:52.001500Z

Hi 👋:skin-tone-2: what is the status of adding OpenAPI3 support (https://github.com/metosin/reitit/issues/84)? I noticed that there has been progress on the linked issues

ikitommi 2021-01-21T14:27:52.003900Z

yes, both spec-tools and schema-tools now have OpenAPI3 support. Just need to be glued together. I think it could start ass an option to swagger. Once it’s tested, could toss away the swagger. Anyone interested in implementing that?

koura 2021-02-02T07:28:19.067900Z

@janne.sauvala I started working on the malli side of OpenAPI3 last autumn but haven't had time to make progress on it for a few months. Now I should be able to progress with it again. I can start to glue the existing solution after that if no one else has started yet

Janne Sauvala 2021-02-02T10:29:12.070200Z

@tommi.jalkanen great news and thanks!

Malik Kennedy 2021-01-21T20:29:43.005300Z

Is there a way to both add something to the response map AND redirect with the new response map? I tried doing something like this but, unless I am missing something else, the key-value pair I added doesnt appear to affect the route that I redirect to.

(defn login-handler [request]
  (let [session (get-in request [:session])
        email (get-in request [:params :email])
        password (get-in request [:params :password])
        valid?   (hashers/verify
                  password
                  (:password
                   (db/get-user-by-email {:email email})))]    
    (if valid?
      (do
        {:status 200
         :body {:identity (jwt/create-token {:id email})}}
        (resp/redirect "/me"))
      (bad-request {:auth [email password]
                    :message "Incorrect Email or Password."}))))

2021-01-21T20:38:53.006300Z

Your do block is defining a map with 2 keys, throwing that map away, and returning the result of calling resp/redirect, which I don’t think is what you intend.

❤️ 1
2021-01-21T20:44:27.008100Z

resp/redirect wants to return a response with a 302 status code, an empty body, and a Location header with the new URL. You could munge the body and put your identity value in there, but I’m not sure what will happen on the client side if you do.

2021-01-21T20:46:28.009300Z

you could try just manually returning

{:status 302
 :headers {"Location" "/me"}
 :body {:identity (jwt/create-token {:id email})}}
and see where that gets you.

❤️ 1
Malik Kennedy 2021-01-21T20:56:50.011Z

Thanks, that gets the redirect working.