metosin / reitit

A fast data-driven routing library for Clojure/Script

Home Page:https://cljdoc.org/d/metosin/reitit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reitit Examples has a bug with Swagger

jasonjckn opened this issue · comments

image

Steps to reproduce

  1. cd reitit/examples/ring-malli-swagger
  2. lein run -m example.server/start
  3. http://localhost:3000/index.html
  4. "Select a definition" and "Swagger" top right corner
  5. Server Error swagger.json

The source code does in fact define swagger.json endpoint.

I also ran into this issue, and commenting out this line makes it so that both the swagger and open api load.

Alternatively, if I define the /download endpoint differently to separate the failing openapi :content, that seems to work, too. Definitely interested in what the guidance is for if you want to support having both swagger and openapi versions.

["/download"
         {:get {:summary "downloads a file"
                :swagger {:produces ["image/png"]}
                :responses {200 {:description "an image"}}
                :openapi {:responses {200 {:content {"image/png" any?}}}}
                :handler (fn [_]
                           {:status 200
                            :headers {"Content-Type" "image/png"}
                            :body (-> "reitit.png"
                                      (io/resource)
                                      (io/input-stream))})}}]

Thanks for noticing that! We forgot to update the example while working on #627

#637 will fix this, but the actual examples won't get fixed until we make a new release. The examples are based on released reitit versions so they won't see the fix from master.

Our intention is to have swagger just ignore the unsupported per-content-type stuff. It was leaking through, which crashed the swagger generation.

see also #639