-
Notifications
You must be signed in to change notification settings - Fork 257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Malli -> Swagger transformation fails with custom registries #558
Comments
If you dereference then you'll have all different types that won't be connected. It's a bad thing in languages such as C#. IMO It depends on language that your front-end is written in. |
...so we can fix metosin#558.
this got accidentally closed by merging metosin/malli#863, but it also needs #589 |
This also happens with openapi. diff --git a/modules/reitit-malli/src/reitit/coercion/malli.cljc b/modules/reitit-malli/src/reitit/coercion/malli.cljc
index 6f4dff5b..5adbcbac 100644
--- a/modules/reitit-malli/src/reitit/coercion/malli.cljc
+++ b/modules/reitit-malli/src/reitit/coercion/malli.cljc
@@ -136,10 +136,13 @@
(defn -get-apidocs-openapi
[coercion {:keys [parameters responses content-types] :or {content-types ["application/json"]}} options]
(let [{:keys [body request multipart]} parameters
+ definitions (volatile! {})
parameters (dissoc parameters :request :body :multipart)
->schema-object (fn [schema opts]
- (let [current-opts (merge options opts)]
- (json-schema/transform schema current-opts)))]
+ (let [current-opts (merge options opts)
+ ret (json-schema/transform schema current-opts)]
+ (vswap! definitions merge (:definitions ret))
+ ret))]
(merge
(when (seq parameters)
{:parameters
@@ -216,7 +219,10 @@
[status (merge (select-keys response [:description])
(when content
{:content content}))])))
- responses)}))))
+ responses)})
+
+ (when (seq @definitions)
+ {:definitions @definitions}))))
(defn create
([] |
for the record, I intend to fix the openapi side once we get some currently open PRs in (e.g. the swagger fix from #642) |
It seems like
malli.json-schema
will place registry entries underdefinitions
which works fine when you feed it with the "full schema" but in case of reitit the transformation is done separately for each schema and thedefinitions
end up in wrong places in swagger.I thought about dereferencing the refs before transformation as a "quick fix" but hesitated.
Originally reported in this Slack thread.
The text was updated successfully, but these errors were encountered: