I'm trying to take a simple map like this an make it consumable by reitit-swagger
(def Org
[:map
[:id Id]
[:ref string?]])
after swagger/transform I get
{:type "object",
:properties {:id {:type "string",
:pattern #"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"},
:ref {:type "string"}},
:required [:id :ref]}
not sure how / where to plug this in to the reitit.swagger
structure
looking at the example in reitit I see this
["/plus"
{:get {:summary "plus with malli query parameters"
:parameters {:query [:map [:x int?] [:y int?]]}
:responses {200 {:body [:map [:total int?]]}}
:handler (fn [{{{:keys [x y]} :query} :parameters}]
{:status 200
:body {:total (+ x y)}})}
:post {:summary "plus with malli body parameters"
:parameters {:body [:map [:x int?] [:y int?]]}
:responses {200 {:body [:map [:total int?]]}}
:handler (fn [{{{:keys [x y]} :body} :parameters}]
{:status 200
:body {:total (+ x y)}})}}]
I can see that I should decorate the Org
with some swagger but still, I'm being dumb cos I can't see how to smash everything together
any clues if you have done this already would be appreciated
@raymcdermott if the swgger-transform output is ok, just use it like {:parameters {:body Org}}
and it works. swagger-transformation is done in the reitit.swagger/create-swagger-handler
code for all parameters & response schemas automatically, it looks the effective :coercion
for a route and asks it to transform the stuff.
you can add stuff with :swagger
namespace or key:
(def Org
[:map {:title "Org"}
[:id {:swagger/description "id"} Id]
[:ref {:swagger {:default "kikka"}} string?]])
hereβs the code: https://github.com/metosin/reitit/blob/master/modules/reitit-swagger/src/reitit/swagger.cljc#L69-L109
ok - great, I'll give a go. Thanks @ikitommi
I can report success π:skin-tone-3: