reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
2020-09-25T06:31:28.009Z

So I’m venturing into the pedestal swagger example https://github.com/metosin/reitit/blob/master/examples/pedestal-swagger/src/example/server.clj and I’m hitting a snag that’s taking me far longer to figure out than I’d like. I’m delineating the parameters for a couple paths and they do not ever appear in my swagger docs, nor am I able to pull them from the [:parameters :query] nor [:parameters :body] locations. It leads me to believe that either I’m horrible at being able to copy the example and am somehow missing an interceptor or have it set up wrong OR there’s something off with the example. I am normally more prone to think it’s me, but I’ve read and re-read my code, comparing it side by side to the example, and I can’t figure out what’s going wrong.

(def router
  (pedestal/routing-interceptor
    (http/router
      [["/swagger.json"
        {:get {
               :no-doc  true
               :swagger {:info {:title "Caller Id API"
                                :description "api for caller ids"}}
               :handler (swagger/create-swagger-handler)}}]
       
       ["/query"
        {:get {:handler    query-get-handler
               :summary    "Fetches caller id information."
               :parameters {:query {:number number?}}
               :responses  {200 {:body string?}}}
         }]
       ["/number"
        {:post {:handler    number-post-handler
                :parameters {:body {:name    string?
                                    :number  string?
                                    :context string?}}
                :responses  {200 {:body string?}}
                :summary    "Adds caller id data to the service."}
         }]
       {:exception pretty/exception
        :data      {
                    :coercion     reitit.coercion.spec/coercion
                    :muuntaja     m/instance
                    :interceptors [swagger/swagger-feature
                                   (parami/parameters-interceptor)
                                   (muuntajai/format-negotiate-interceptor)
                                   (muuntajai/format-response-interceptor)
                                   (exi/exception-interceptor)
                                   (muuntajai/format-request-interceptor)
                                   (coercion/coerce-response-interceptor)
                                   (coercion/coerce-request-interceptor)
                                   (multii/multipart-interceptor)]
                    }}])

    ;; optional default ring handlers (if no routes have matched)
    (ring/routes
      (swagger-ui/create-swagger-ui-handler {:path   "/"
                                             :config {:validatorUrl     nil
                                                      :operationsSorter "alpha"}})

      (ring/create-resource-handler)

      (ring/create-default-handler)
      )


    ;; optional top-level routes for both routes & default route
    {:interceptors [(muuntaja.interceptor/format-interceptor)
                    ;(interceptor :top)
                    ]})

  )
The context returns my parameters in a number of keys, one of them the ‘params’ keys. Am I missing or misconfiguring an interceptor or something?

2020-09-26T07:15:50.009900Z

Found my error. Failing to insure the proper placement of the final map in the route definition. I think that’s a record time lost for me to an off by one level in my parens. Sorry if anyone has lost any time to this.