mirror of
https://github.com/metosin/reitit.git
synced 2025-12-29 04:38:26 +00:00
Merge pull request #624 from metosin/openapi-descriptions-malli
fix: openapi malli parameter descriptions
This commit is contained in:
commit
6b378ffbf5
2 changed files with 17 additions and 4 deletions
|
|
@ -145,14 +145,14 @@
|
|||
(when (seq parameters)
|
||||
{:parameters
|
||||
(->> (for [[in schema] parameters
|
||||
:let [{:keys [properties required] :as root} (->schema-object schema {:in in :type :parameter})
|
||||
:let [{:keys [properties required]} (->schema-object schema {:in in :type :parameter})
|
||||
required? (partial contains? (set required))]
|
||||
[k schema] properties]
|
||||
(merge {:in (name in)
|
||||
:name k
|
||||
:required (required? k)
|
||||
:schema schema}
|
||||
(select-keys root [:description])))
|
||||
(select-keys schema [:description])))
|
||||
(into []))})
|
||||
(when body
|
||||
;; body uses a single schema to describe every :requestBody
|
||||
|
|
|
|||
|
|
@ -365,9 +365,10 @@
|
|||
|
||||
(deftest all-parameter-types-test
|
||||
(doseq [[coercion ->schema]
|
||||
[[#'malli/coercion (fn [nom] [:map [nom :string]])]
|
||||
[[#'malli/coercion (fn [nom] [:map [nom [:string {:description (str "description " nom)}]]])]
|
||||
[#'schema/coercion (fn [nom] {nom s/Str})]
|
||||
[#'spec/coercion (fn [nom] {nom string?})]]]
|
||||
[#'spec/coercion (fn [nom] {nom (st/spec {:spec string?
|
||||
:description (str "description " nom)})})]]]
|
||||
(testing coercion
|
||||
(let [app (ring/ring-handler
|
||||
(ring/router
|
||||
|
|
@ -395,18 +396,30 @@
|
|||
(is (match? [{:in "query"
|
||||
:name "q"
|
||||
:required true
|
||||
:description (if (not= #'schema/coercion coercion)
|
||||
"description :q"
|
||||
"")
|
||||
:schema {:type "string"}}
|
||||
{:in "header"
|
||||
:name "h"
|
||||
:required true
|
||||
:description (if (not= #'schema/coercion coercion)
|
||||
"description :h"
|
||||
"")
|
||||
:schema {:type "string"}}
|
||||
{:in "cookie"
|
||||
:name "c"
|
||||
:required true
|
||||
:description (if (not= #'schema/coercion coercion)
|
||||
"description :c"
|
||||
"")
|
||||
:schema {:type "string"}}
|
||||
{:in "path"
|
||||
:name "p"
|
||||
:required true
|
||||
:description (if (not= #'schema/coercion coercion)
|
||||
"description :p"
|
||||
"")
|
||||
:schema {:type "string"}}]
|
||||
(-> spec
|
||||
(get-in [:paths "/parameters" :post :parameters])
|
||||
|
|
|
|||
Loading…
Reference in a new issue