This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-06-21
Channels
- # announcements (9)
- # beginners (222)
- # boot (11)
- # calva (40)
- # cider (1)
- # clj-kondo (10)
- # cljs-dev (1)
- # cljsrn (8)
- # clojars (4)
- # clojure (50)
- # clojure-dev (4)
- # clojure-ecuador (1)
- # clojure-europe (4)
- # clojure-italy (3)
- # clojure-madison (2)
- # clojure-nl (26)
- # clojure-spec (86)
- # clojure-uk (34)
- # clojurescript (11)
- # clr (1)
- # cursive (46)
- # datomic (19)
- # emacs (4)
- # events (1)
- # fulcro (22)
- # graalvm (4)
- # graphql (2)
- # jobs-discuss (40)
- # leiningen (10)
- # luminus (6)
- # nrepl (7)
- # off-topic (18)
- # onyx (6)
- # overtone (1)
- # pedestal (2)
- # planck (1)
- # re-frame (5)
- # reagent (3)
- # reitit (8)
- # rewrite-clj (2)
- # shadow-cljs (139)
- # sql (4)
- # tools-deps (42)
Is it possible to set a maximum number with schema-tools and swagger support?
Howdy fam! how do i add http header to the following
["/upload"
{: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)}})}}]
when i try :parameters
{:header "custom-header" "custom-value"}
I get spec errors like Request coercion failed: #reitit.coercion.CoercionError{:spec #Spec{:form (clojure.spec.alpha/keys :req-un [:spec$2980/custom-header])
I think if it were me I’d make the handler fn take the request object directly, and then pull out the parts that I wanted. The :headers
key is in the request at the same level as the :parameters
key so if you do what to do destructuring, I think it would have to look something like this
(fn [{{{:keys [file]} :multipart} :parameters
{custom-value "custom-header"} :headers}]
{:status 200
:custom-header custom-value
:body {:name (:filename file)
:size (:size file)}})
None of these seem to work. {:post {:headers ...} or {:post {:parameters {:headers .. } or {:post {:parameters {:header .. } the last one at least shows up in the swagger window but i still get spec coercion errors
@kbosompem maybe {:parameters {:header {:custom-header string?}}}
@mitchelkuijpers I think so, you can have something like (s/constrained s/Int #(< % 10))
to add guard for the validation and add :swagger/maximum 10
to get the swagger docs too
