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

The server is starting fine but the Swagger UI in the frontend is flashing an error

Abrar-Ahmed7 opened this issue · comments

After adding this middleware (io.pedestal.http.ring-middlewares/content-type {:mime-types {}}) along with

(pedestal/routing-interceptor
                         (reitit-http/router (routes)
                                             (reitit-router-config))
                         (ring/routes (swagger-ui/create-swagger-ui-handler
                                       {:path "/api-docs"
                                        :config {:validatorUrl nil
                                                 :operationsSorter "alpha"}})
                                      (ring/create-resource-handler)
                                      (ring/create-default-handler)))

to my ::http/interceptors of my service-map which is being used to create and start the server, the server is starting fine but the Swagger UI in the frontend is flashing an error like,

Parser error on line 2
unexpected end of the stream within a flow collection

And the response to the swagger endpoint/swagger.json returns,

{
    : swagger "2.0",
    : x-id#{
        : reitit.swagger/default
    },
    : info{
        : title "Export Service API",
        : description "with pedestal & reitit-http"
    },
    .
    .
    .
    <rest-of-the-json-data>
    .
 }

What would be the issue here? Can I overcome this in my code base itself?
Additional info:

  • Without this this middleware (io.pedestal.http.ring-middlewares/content-type {:mime-types {}}) everything working fine.
  • These are the dependencies I am using:
     [fi.metosin/reitit-malli "0.7.0-alpha6"]
     [fi.metosin/reitit-pedestal "0.7.0-alpha6"]
     [fi.metosin/reitit "0.7.0-alpha6"]
     [metosin/ring-swagger-ui "5.0.0-alpha.0"]
     [io.pedestal/pedestal.service "0.5.10"]
     [io.pedestal/pedestal.route "0.5.10"]
     [io.pedestal/pedestal.jetty "0.5.10"]
Screenshot 2023-11-29 at 9 23 17 PM Screenshot 2023-11-29 at 9 23 51 PM

Looks like your like swagger.json is EDN instead of JSON. Maybe you're missing some content-negotiation or format middleware? I'm not familiar with pedestal so I can't help with that, but perhaps the pedestal-malli-swagger example will help you.