Fork me on GitHub
#ring-swagger
<
2018-01-19
>
drewverlee03:01:06

Anyone able to help me understand why my path param isn’t being coerced to a int like i would expect? It also validate (complain) if the input can’t be coerced to an int.

(s/def ::id spec/int?)

(def app
  (api
   {:coercion :spec
    :swagger
     {:ui "/"
      :spec "/swagger.json"
      :data {:info {:title "ResoluteAPI"
                    :description "API endpoint around customer portfolios"}
             :tags [{:name "Equipments", :description "A api for the equipments page"}]}}}

    (context "/api" []
             
      :tags ["api"]

      (GET "/equipment/:equipment-id/points" []
           :return ::points
           :path-params [equipment-id :- ::id]
           :summary "returns all points for a given equipment"
           (ok {:hi equipment-id})))))


(-> {:uri "/api/equipment/3/points"
     :request-method :get}
    app
    :body
    slurp
    (cheshire.core/parse-string true))

;;{:hi "3"}

drewverlee12:01:21

updated the deps and everything works fine

psalaberria00214:01:19

how do I set an example request body in a compojure-api endpoint?

psalaberria00214:01:31

I have seen it before, but I can’t remember