mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 17:01:11 +00:00
feat: change syntax for :request parameter coercion default schema
use :request :body instead of :request :content :default for symmetry with :response
This commit is contained in:
parent
7842160656
commit
c3a3ca9f95
2 changed files with 8 additions and 7 deletions
|
|
@ -87,11 +87,12 @@
|
||||||
(if-let [{:keys [keywordize? open? in style]} (parameter-coercion type)]
|
(if-let [{:keys [keywordize? open? in style]} (parameter-coercion type)]
|
||||||
(let [transform (comp (if keywordize? walk/keywordize-keys identity) in)
|
(let [transform (comp (if keywordize? walk/keywordize-keys identity) in)
|
||||||
->open (if open? #(-open-model coercion %) identity)
|
->open (if open? #(-open-model coercion %) identity)
|
||||||
format-coercer-pairs (if (= :request style)
|
format-schema-pairs (if (= :request style)
|
||||||
(for [[format schema] (:content model)]
|
(conj (:content model) [:default (:body model)])
|
||||||
[format (-request-coercer coercion :body (->open schema))])
|
[[:default model]])
|
||||||
[[:default (-request-coercer coercion style (->open model))]])
|
format->coercer (some->> (for [[format schema] format-schema-pairs
|
||||||
format->coercer (some->> format-coercer-pairs
|
:when schema]
|
||||||
|
[format (-request-coercer coercion (case style :request :body style) (->open schema))])
|
||||||
(filter second)
|
(filter second)
|
||||||
(seq)
|
(seq)
|
||||||
(into {}))]
|
(into {}))]
|
||||||
|
|
|
||||||
|
|
@ -610,8 +610,8 @@
|
||||||
(let [app (ring/ring-handler
|
(let [app (ring/ring-handler
|
||||||
(ring/router
|
(ring/router
|
||||||
[["/foo" {:post {:parameters {:request {:content {"application/json" json-request
|
[["/foo" {:post {:parameters {:request {:content {"application/json" json-request
|
||||||
"application/edn" edn-request
|
"application/edn" edn-request}
|
||||||
:default default-request}}}
|
:body default-request}}
|
||||||
:responses {200 {:content {"application/json" json-response
|
:responses {200 {:content {"application/json" json-response
|
||||||
"application/edn" edn-response}
|
"application/edn" edn-response}
|
||||||
:body default-response}}
|
:body default-response}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue