mirror of
https://github.com/metosin/reitit.git
synced 2026-02-18 16:55:55 +00:00
refactor: push openapi/openapi-spec call inside merge
to make reitit.coercion.spec match reitit.coercion.schema
This commit is contained in:
parent
41c4d78823
commit
bcd12d9f31
1 changed files with 33 additions and 34 deletions
|
|
@ -107,13 +107,12 @@
|
||||||
(if (:schema $)
|
(if (:schema $)
|
||||||
(update $ :schema #(coercion/-compile-model this % nil))
|
(update $ :schema #(coercion/-compile-model this % nil))
|
||||||
$))]))})))
|
$))]))})))
|
||||||
:openapi (openapi/openapi-spec
|
:openapi (merge
|
||||||
(merge
|
|
||||||
(when (seq (dissoc parameters :body :request))
|
(when (seq (dissoc parameters :body :request))
|
||||||
{::openapi/parameters
|
(openapi/openapi-spec {::openapi/parameters
|
||||||
(into (empty parameters)
|
(into (empty parameters)
|
||||||
(for [[k v] (dissoc parameters :body :request)]
|
(for [[k v] (dissoc parameters :body :request)]
|
||||||
[k (coercion/-compile-model this v nil)]))})
|
[k (coercion/-compile-model this v nil)]))}))
|
||||||
(when (:body parameters)
|
(when (:body parameters)
|
||||||
{:requestBody (openapi/openapi-spec
|
{:requestBody (openapi/openapi-spec
|
||||||
{::openapi/content (zipmap content-types (repeat (coercion/-compile-model this (:body parameters) nil)))})})
|
{::openapi/content (zipmap content-types (repeat (coercion/-compile-model this (:body parameters) nil)))})})
|
||||||
|
|
@ -140,7 +139,7 @@
|
||||||
(when response
|
(when response
|
||||||
(into {}
|
(into {}
|
||||||
(for [[format model] (:content response)]
|
(for [[format model] (:content response)]
|
||||||
[format (coercion/-compile-model this model nil)]))))})))]))})))
|
[format (coercion/-compile-model this model nil)]))))})))]))}))
|
||||||
(throw
|
(throw
|
||||||
(ex-info
|
(ex-info
|
||||||
(str "Can't produce Spec apidocs for " specification)
|
(str "Can't produce Spec apidocs for " specification)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue