Fork me on GitHub
#malli
<
2023-08-13
>
hifumi12308:08:35

I have an application using reitit for routers and swagger docs. My endpoints all respond with data conforming to some malli schema. Is it possible to convert the these schemas into models in the swagger docs? For a concrete example, I have route data that looks like this

["/thing/:id" 
 {:get
  {:handler get-thing
   :responses {200 {:description "Successful response"
                    :body Thing}
               404 {:description "Not found"
                    :body Anomaly}}}}]
and I would like the Thing and Anomaly schemas to become models in the swagger docs. I am able to get Malli to convert the map schemas into Swagger data, but I am not sure how to embed it into the Swagger UI.

ikitommi09:08:18

Not sure what is the problem. All malli-schemas get converted into swagger schemas out of the box?

hifumi12309:08:37

Sorry. Looks like there isnt a problem. Basically, the demo Swagger UI has a dedicated “models” section and I wanted to achieve this with Malli schemas

hifumi12309:08:04

It turns out this dedicated models section is only available with OpenAPI 3.0, not Swagger 2.0

ikitommi09:08:44

OpenAPI3.x support should land in few weeks 😎

👀 4
😎 2