ring-swagger

ring-swagger & compojure-api
2018-01-19T03:06:06.000035Z

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"}

2018-01-19T12:53:21.000259Z

updated the deps and everything works fine

👍 1
psalaberria002 2018-01-19T14:38:19.000372Z

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

psalaberria002 2018-01-19T14:38:31.000358Z

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

👍 1