Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EDN appears to break body text editor #17

Open
SVMBrown opened this issue Jan 17, 2021 · 5 comments
Open

EDN appears to break body text editor #17

SVMBrown opened this issue Jan 17, 2021 · 5 comments

Comments

@SVMBrown
Copy link

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
Copy link
Member

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

@SVMBrown
Copy link
Author

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
Copy link
Author

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
Copy link
Member

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

@alexiaharal
Copy link

Is this fixed? I am facing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants