Fork me on GitHub
#reitit
<
2023-11-30
>
Tulio16:11:29

Hi everyone, I'm using reitit with openapi specification and I would like to know how can we set a schema to be used across different endpoints? When I try to add my malli schema to components I get an error from muuntaja

:openapi {:info {:title "My API" :version "0.0.1"}
:servers [{:url ""}]
:components {:securitySchemes {"auth" {:type :apiKey
                                       :in :header
                                       :name "x-authorization"}}
             :schemas {"my-schema" c/my-malli-schema-in-another-file}}}

Tulio16:11:09

and the error is

{
    "cause1": "com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class malli.core$_or_schema$reify$reify__14536 and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: clojure.lang.PersistentArrayMap[&quot;:components&quot;]->clojure.lang.PersistentArrayMap[&quot;:schemas&quot;]->clojure.lang.PersistentArrayMap[&quot;facilities&quot;])",
    "cause0": "clojure.lang.ExceptionInfo: Malformed application/json in :muuntaja/encode {:type :muuntaja/encode, :format &quot;application/json&quot;}",
    "message": "clojure.lang.ExceptionInfo: Malformed application/json in :muuntaja/encode {:type :muuntaja/encode, :format &quot;application/json&quot;}",
    "url": "/glms/openapi.json",
    "status": "500"

Tulio16:11:34

PS: I'm already using this schema in the response body and works. but when I try to add as :schemas not. So I don't know if what I'm doing is correct or not