refactor: no need to pass options into -get-apidocs-openapi

This commit is contained in:
Joel Kaasinen 2023-08-28 08:59:58 +03:00
parent ee298ec362
commit f943b025cb

View file

@ -133,12 +133,8 @@
;; malli options
:options nil})
;; TODO: this is now seems like a generic transforming function that could be used in all of malli, spec, schema
;; ... just tranform the schemas in place
;; also, this has internally massive amount of duplicate code, could be simplified
;; ... tests too
(defn -get-apidocs-openapi
[coercion {:keys [request parameters responses content-types] :or {content-types ["application/json"]}} options]
[coercion {:keys [request parameters responses content-types] :or {content-types ["application/json"]}}]
(let [{:keys [body multipart]} parameters
parameters (dissoc parameters :request :body :multipart)
->content (fn [data schema]
@ -146,7 +142,7 @@
{:schema schema}
(select-keys data [:description :examples])
(:openapi data)))
->schema-object #(coercion/-get-model-apidocs coercion :openapi %1 (merge options %2))]
->schema-object #(coercion/-get-model-apidocs coercion :openapi %1 %2)]
(merge
(when (seq parameters)
{:parameters
@ -243,7 +239,7 @@
(-get-options [_] opts)
(-get-model-apidocs [this specification model options]
(case specification
:openapi (json-schema/transform model options)
:openapi (json-schema/transform model (merge opts options))
(throw
(ex-info
(str "Can't produce Malli apidocs for " specification)
@ -268,7 +264,7 @@
(if (:schema $)
(update $ :schema swagger/transform {:type :schema})
$))]))}))
:openapi (-get-apidocs-openapi this data options)
:openapi (-get-apidocs-openapi this data)
(throw
(ex-info
(str "Can't produce Malli apidocs for " specification)