Compojure.api param destructuring and coercion

I’ve been using compojure.api for the coercion of request parameters, but I do not fully understand what is every aspect of the syntax means and I could not find answers in the documentation.

This documentation provides the following example:

(GET "/roll/:n/:s" []
  :path-params [n :- s/Int
                s :- s/Int]
  :return Result
  :summary "Rolls :n dice of sides :s"
  (ok (roll-dice n s)))

and describes the [n :- s/Int s :- s/Int] as “a vector of names assigned to schema”
What does :- actually mean? Where can I find the documentation of this? Are there alternatives to :-? I would expect so, otherwise the :- could be omitted.

Another question specifically for destructuring and the coercion of maps:

:query-params [{v :- ::version 1}]

What happens here exactly? (I realize that in this example spec is used for coercion).

compojure-api loans Schema syntax helpers from Schema & Plumbing libraries. More info here:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.