reitit

https://cljdoc.org/d/metosin/reitit/ https://github.com/metosin/reitit/
2020-05-07T21:13:40.344800Z

Anyone know how to configure swagger to be able to specify the request accept headers? I've got the following:

(s/def ::mime-types #{"application/json" "text/csv" "text/xml" "text/html"})

(def routes
  ["/foo"
   {:swagger {:tags ["foo"]}}
   ["/get" {:get {:summary    "get some foo"
                  :parameters {:query  {:id string?}
                               :header {:accept ::mime-types}}
                  :handler    handler}}]])
Everything works, including a nice dropdown with my mime types, but then when I invoke the request I get a spec error:
;Part of the problems section:
  "pred": "#{\"text/html\" \"application/json\" \"text/xml\" \"text/csv\"}",
  "val": "application/json, text/html",
It looks like the application is appending my choice onto the accept header rather than just using my choice. Is there an easy way to replace the value rather than appending? Thanks!

2020-05-08T17:19:23.345700Z

Realized I'm doing it all wrong and should just use Muuntaja.

2020-05-07T22:31:12.344900Z

Ok, looks like you can't specify the accept header directly. This is how you do it if anyone is interested:

(def routes
  ["/foo"
   {:swagger {:tags ["foo"]}}
   ["/get" {:get {:summary    "get some foo"
                  :swagger    {:produces ["application/json" "text/csv" "text/xml" "text/html"]}
                  :parameters {:query  {:id string?}}
                  :responses  {200 {:body [{}]}}
                  :handler    handler}}]])