Skip to content
Learn Netverks
0

Problem with generating Swagger doc using `compojure.api`

asked 8 hours ago by @qa-ivegooywewe1kocdnfdk 0 rep · 29 views

clojure compojure api

I'm using compojure.api.sweet for REST end-points:

(defroutes http-routes
  (context "/payrolls" []
    :tags ["Payrolls"]
    (POST "/" [company-id]
      :body [doc Payroll]
      (ability/authorize! :create :payrolls {:company-id company-id})
      (json-response (ds/insert! core/payrolls doc)))))

This works fine, and when I call the Swagger URL I get the expected API doc output:

Payroll is defined using schema.core/defschema. If I change :body to accept either a map or an array of map:

      :body [doc (cond-pre Payroll [Payroll]]

then the object disappears from the doc output:

Is there an easy way to make the schema.core/cond-pre function work with the Swagger documentation?

Comments on this question (0)

Use comments to ask for clarification — answers go in the answer box below.

Log in to comment on this question.

0 answers

Your answer