Fork me on GitHub
#reitit
<
2018-07-02
>
ikitommi08:07:17

@vale depends on the coercion model you are using. There could be more examples on the docs. PRs welcome. Some samples:

;; schema
(require '[schema.core :as s])
:query {:x s/Int, (s/optional-key :y) s/Int}

;; data-specs
(require '[spec-tools.data-spec :as ds])
:query {:x int?, (ds/opt :y) int?}

;; clojure.spec
(require '[clojure.spec.alpha :as sa])
(require '[spec-tools.spec :as spec])
(sa/def ::x spec/int?)
(sa/def ::y spec/int?)
:query (sa/keys :req-un [::x] :opt-un [::y])
... should all do the same.

ikitommi08:07:55

@yogthos no helpers currently in reitit for upload (or download), I think there should be, in reitit-ring module. Ideas welcomr on what would be a easy syntax to define those.

ikitommi08:07:49

Currently, one can use the normal ring middleware for multipart, but I think we can do better.

ikitommi08:07:35

1) the schemas for multipart for schema & spec 2) mw to read the params for multipart/form-data (could be a format in Muuntaja? 3) data-driven syntax to pull the params, maybe after rhe openapi3 additions?

:content {"multipart/form-data" {:body {:name string?, :file file?}}}

ikitommi08:07:56

the 3rd explained: for the multipart-endpoints, there is only one content-type allowed, Muuntaja format parses that (and emits the openapi-docs).

ikitommi09:07:36

btw, currently on vacation, back to computer in few weeks..

👍 8
roklenarcic22:07:29

Weird, if I add :compile reitit.coercion/compile-request-coercers to my ring router, all my responses become 405 code.