metosin / reitit

A fast data-driven routing library for Clojure/Script
https://cljdoc.org/d/metosin/reitit/
Eclipse Public License 1.0
1.42k stars 254 forks source link

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

Open Abrar-Ahmed7 opened 10 months ago

Abrar-Ahmed7 commented 10 months ago

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:

Screenshot 2023-11-29 at 9 23 17 PM Screenshot 2023-11-29 at 9 23 51 PM
opqdonut commented 5 months ago

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.