metosin / ring-swagger-ui

Swagger UI packaged for Ring Apps
50 stars 22 forks source link

EDN appears to break body text editor #17

Open SVMBrown opened 3 years ago

SVMBrown commented 3 years ago

When providing a body to Swagger with type application/edn, the "Execute" button doesn't do anything (unless it is valid JSON as well). A request body that is valid JSON but invalid EDN gets properly sent and a helpful "malformed EDN" error is returned.

I am using ring-swagger-ui via reitit's swagger module with this dependency version [metosin/reitit "0.5.11"]. It is either an issue with my understanding of the configuration, or something with the UI component itself. I am unable to get the request to send, and see no error in the web console. It isn't frozen or anything, because it functions properly if I edit the POST body to be {} which is valid EDN and JSON, or {"some": "JSON"} which returns the parsing error. Additionally, if I send valid JSON it all behaves as expected and I get the correct responses from my endpoints.

The fact that it won't even send the request makes me suspect the UI or the configuration of the UI, but if there's something I've overlooked I'd appreciate the help.

For reference here's my setup:

My API routes look like this:

["/api"
   {:middleware [parameters/parameters-middleware
                 muuntaja/format-negotiate-middleware
                 muuntaja/format-response-middleware
                 exception/exception-middleware
                 muuntaja/format-request-middleware
                 coercion/coerce-response-middleware
                 coercion/coerce-request-middleware
                 multipart/multipart-middleware]
    :muuntaja formats/instance
    :coercion spec-coercion/coercion
    :swagger {:id ::api}}
   ["" {:no-doc true}
    ["/swagger.json"
     {:get (swagger/create-swagger-handler)}]
    ["/swagger-ui*"
     {:get (swagger-ui/create-swagger-ui-handler
            {:url "/api/swagger.json"})}]]
;; My API Endpoints
]

and my post endpoint looks like this:

{:post
     {:parameters
      {:body
       {:name string?
        :message string?}}
      :responses
      {200 {:body map?}
       400 {:body map?}
       500 {:errors map?}}
      :handler
      (fn [req]
       ;; My handler
)}
ikitommi commented 3 years ago

Root cause in in the seagger-ui itself. does this work with newer versions of that?

SVMBrown commented 3 years ago

Looks like it may be related to this issue that is still open. Will see what I can do on my end, but it seems that the only thing to do is wait for them to fix it and then bump versions.

SVMBrown commented 3 years ago

Still broken as of swagger-ui 3.43.0 I've added a comment to the issue referenced above. Hopefully they address it so that it can be included here.

ikitommi commented 3 years ago

Commented also the issue. Hopefully there will be a quick fix for this.

alexiaharal commented 3 weeks ago

Is this fixed? I am facing the same issue.