Closed
Description
I am trying to organice my routes in separated files by their type/task (contacts, users, items, etc.) and then importing all of them in one main file in which I have configured the swagger documentation. However, all routes that have been imported from other files aren't being considered by swagger.
This is a extract of my main route table (swagger configuration belongs here):
(defn api-endpoint [{users-db :users-db contacts-db :contacts-db :as config}]
(api
(ring.swagger.ui/swagger-ui
"/swagger-ui")
(swagger-docs
{:info {:title "SimpleClerk API"
:description "SimpleClerk's CRM API"
:tags [{:name "users" :description "Application's users."}
{:name "contacts"}
{:name "contacts_v2"}]}})
(context* "/api/v1" []
:tags ["api"]
(context* "/users" []
:tags ["users"]
(GET* "/" []
:return [UserSchema]
:summary "Return the list of users."
(ok (fetch-users users-db)))
;; ...
(DELETE* "/:id" []
:return s/Int
:path-params [id :- s/Uuid]
:summary "Delete the user with a given id."
(ok (delete-user! users-db id))))
(context* "/contacts" []
:tags ["contacts"]
;; importing contacts routes
(contacts-endpoint contacts-db)
;; adding a dummy route for testing purposes
(GET* "/foo" []
:return s/Int
:summary "Dummy route"
(ok 1))
)
)))
And my contacts routes files looks like this:
(defn contacts-endpoint [db]
(defroutes* contacts-route []
(GET* "/" []
:return [Contact]
:summary "Return the list of contacts."
(ok (fetch-contacts db)))
(POST* "/" []
:return s/Uuid
:body [contact Contact]
:summary "Create a contact record."
(ok (create-contact! db contact)))
))
You can see here that my configuration only shows me the dummy route and not the ones that I imported from the other file.
I am sure that those external routes are working because I can request them without problems. Any idea of what could be wrong in my configuration?