Hi there - from the docs / reading the code I think the answer is no, but just in case: Is it possible to create a reitit http router (not ring) that accepts interceptors as the handlers rather than ring-style request->response functions? My use case is wanting to replace the router in code that currently uses Pedestal and has all the handlers implemented as interceptors without having to rewrite the handlers (and handle the fact that many of them expect the full context to be available rather than just the request). Thanks!
With http-router, :handler gets coerced into interceptor using reitit.interceptor/IntoInterceptor protocol. Function is mapped to ring-style req-res thing, but just use anything else and it should just work.
(let [app (http/ring-handler
(http/router
["/" {:handler {:enter #(assoc % :response {:status 200, :body "fine"})}}])
nil
{:executor sieppari/executor})]
(app {:request-method :get, :uri "/"}))
; => {:status 200, :body "fine"}not sure if that is what you asked thou 🙂
Huh - when I tried I got some errors about interceptors not conforming to IntoInterceptor protocol I think 🤔 - I’ll have another look, thanks
Thanks a lot for the response and making me look at it again, turns out some of the interceptors were pedestal Interceptor records rather than just maps which is why IntoInterceptor was failing picard-facepalm
folks, I have the following plumatic schema:
;; (s/defschema BirthdayRequest (st/open-schema {:name s/Str
;; :birthday s/Str}))
which is an open schema so my request body is a tolerant reader, and it is added this way into reitit router
;; [["/birthday"
;; {:post {:parameters {:body requests.birthday/BirthdayRequest}
;; :handler birthday-add-handler}}]
but on swagger, I get the following as the request body schema, with additional parameters that I didn't want to document (as in the image)
how should I define my schema so there additional properties aren't generated?FYI, those additionalProp keys are added by swagger ui, they're not inserted into the swagger.json by reitit
not sure what's the easiest way to avoid that...
also, if my response returns a status code of 204 with no parameters, if I define the response as follows:
["/birthday/delete/{birthday-id}"
{:delete {:parameters {:path {:birthday-id s/Uuid}}
:responses {204 {:body nil}
it shows as "string" on the response, how do I make not show anything?try 204 {} instead
didn't work, same thing apparently 😕