Welcome! Please see the About page for a little more info on how this works.

0 votes
in Libs by

Hey! I'm getting an unmatched paren error on this function I got from reitit's example http-swagger project.

(def app
        {:get {:no-doc true
         :swagger {:info {:title "my-api"
                          :description "with reitit-http"}}
         :handler (swagger/create-swagger-handler)}}]

  {:swagger {:tags ["files"]}}

   {:post {:summary "upload a file"
           :parameters {:multipart {:file multipart/temp-file-part}}
           :responses {200 {:body {:name string?, :size int?}}}
           :handler (fn [{{{:keys [file]} :multipart} :parameters}]
                      {:status 200
                       :body {:name (:filename file)
                              :size (:size file)}})}}]

  {:get {:swagger {:tags ["async"]}
         :summary "fetches random users asynchronously over the internet"
         :parameters {:query (s/keys :req-un [::results] :opt-un [::seed])}
         :responses {200 {:body any?}}
         :handler (fn [{{{:keys [seed results]} :query} :parameters}]
                      {:query-params {:seed seed, :results results}})
                     (partial m/decode "application/json")
                     (fn [results]
                       {:status 200
                        :body results})))}}]

  {:swagger {:tags ["math"]}}

   {:get {:summary "plus with data-spec query parameters"
          :parameters {:query {:x int?, :y int?}}
          :responses {200 {:body {:total pos-int?}}}
          :handler (fn [{{{:keys [x y]} :query} :parameters}]
                     {:status 200
                      :body {:total (+ x y)}})}
    :post {:summary "plus with data-spec body parameters"
           :parameters {:body {:x int?, :y int?}}
           :responses {200 {:body {:total int?}}}
           :handler (fn [{{{:keys [x y]} :body} :parameters}]
                      {:status 200
                       :body {:total (+ x y)}})}}]

   {:get {:summary "minus with clojure.spec query parameters"
          :parameters {:query (s/keys :req-un [::x ::y])}
          :responses {200 {:body (s/keys :req-un [::total])}}
          :handler (fn [{{{:keys [x y]} :query} :parameters}]
                     {:status 200
                      :body {:total (- x y)}})}
    :post {:summary "minus with clojure.spec body parameters"
           :parameters {:body (s/keys :req-un [::x ::y])}
           :responses {200 {:body (s/keys :req-un [::total])}}
           :handler (fn [{{{:keys [x y]} :body} :parameters}]
                      {:status 200
                       :body {:total (- x y)}})}}]]]

{:reitit.interceptor/transform dev/print-context-diffs ;; pretty context diffs
 :validate spec/validate ;; enable spec validation for route data
 :reitit.spec/wrap spell/closed ;; strict top-level validation
 :exception pretty/exception
 :data {:coercion reitit.coercion.spec/coercion
        :muuntaja m/instance
        :interceptors [;; swagger feature
                       ;; query-params & form-params
                       ;; content-negotiation
                       ;; encoding response body
                       ;; exception handling
                       ;; decoding request body
                       ;; coercing response bodys
                       ;; coercing request parameters
                       ;; multipart
 {:path "/"
  :config {:validatorUrl nil
           :operationsSorter "alpha"}})
 {:executor sieppari/executor}))

2 Answers

0 votes

Probably best to file an issue at https://github.com/metosin/reitit/issues.

0 votes

Try an extra ] to close the vector on line 70 (the line with :body {:total (- x y)}})}}]]] ). And, yeah, as @alexmiller says, best to file an issue with reitit.

Welcome to Clojure Q&A, where you can ask questions and receive answers from members of the Clojure community.