Skip to content

Commit

Permalink
fix: don't output :default in openapi request body
Browse files Browse the repository at this point in the history
  • Loading branch information
Martín Varela committed Feb 9, 2024
1 parent 23d4268 commit 8d0cec8
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions modules/reitit-openapi/src/reitit/openapi.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[clojure.spec.alpha :as s]
[clojure.string :as str]
[meta-merge.core :refer [meta-merge]]
[muuntaja.core :as m]
[reitit.coercion :as coercion]
[reitit.core :as r]
[reitit.trie :as trie]))
Expand Down Expand Up @@ -77,26 +76,17 @@
(-> path (trie/normalize opts) (str/replace #"\{\*" "{")))

(defn -get-apidocs-openapi
[coercion {:keys [request parameters responses openapi/request-content-types openapi/response-content-types muuntaja]
:or {request-content-types ["application/json"]
response-content-types ["application/json"]} :as r}]
[coercion {:keys [request parameters responses openapi/request-content-types openapi/response-content-types]
:or {request-content-types ["application/json"]
response-content-types ["application/json"]}}]
(let [{:keys [body multipart]} parameters
parameters (dissoc parameters :request :body :multipart)
->content (fn [data schema]
(merge
{:schema schema}
(select-keys data [:description :examples])
(:openapi data)))
->schema-object #(coercion/-get-model-apidocs coercion :openapi %1 %2)
#_ request-content-types #_ (if (some? muuntaja)
(into [] (m/decodes muuntaja))
["application/json"])
#_ response-content-types #_ (if (some? muuntaja)
(into [] (m/encodes muuntaja))
["application/json"])
]
#_ (tap> request)
#_ (tap> responses)
->schema-object #(coercion/-get-model-apidocs coercion :openapi %1 %2)]
(merge
(when (seq parameters)
{:parameters
Expand Down Expand Up @@ -127,7 +117,6 @@
{:content (merge
(select-keys request [:description])
(when-let [{:keys [schema] :as data} (coercion/get-default request)]
(tap> data)
(into {}
(map (fn [content-type]
(let [schema (->schema-object schema {:in :requestBody
Expand All @@ -141,7 +130,7 @@
:type :schema
:content-type content-type})]
[content-type (->content data schema)])))
(:content request)))}})
(dissoc (:content request) :default)))}})
(when multipart
{:requestBody
{:content
Expand Down

0 comments on commit 8d0cec8

Please sign in to comment.