Skip to content

Untraceable error with Swagger UI for GET method that requires a body. #251

Closed
@code-ape

Description

@code-ape

Verified for:

  • [org.clojure/clojure "1.8.0"]
  • [compojure "1.5.1"]
  • [ring/ring-defaults "0.2.1"]
  • [metosin/compojure-api "1.1.8"] and [metosin/compojure-api "1.1.7"]
  • Running with lein ring server-headless

Issue

A method declared as GET which only takes a body fails, such as this one:

(GET "/foo" []
     :return {:foo s/Str}
     :body [f {:foo s/Str}]
     :summary "An example"
     (ok f))

fails without a traceable explanation on the server console output. The Swagger UI only says:

response Body
{
  "errors": "(not (map? nil))"
}

Response Code
400

Response Headers
{
  "date": "Mon, 03 Oct 2016 02:38:57 GMT",
  "server": "Jetty(7.6.13.v20130916)",
  "content-length": "29",
  "content-type": "application/json; charset=utf-8"
}

This appears to be related to the GET method as changing this to a POST fixes this problem.

Also, this issue doesn't occur when using curl, as the following succeeds with the appropriate response:

$ curl -X GET --header 'Content-Type: application/json' \ 
  --header 'Accept: application/json' -d '{ "foo": "string" }' \
  'http://192.168.50.50:3000/api/v1/foo'

Regardless though the failure from the Swagger UI still indicates an issue with the library and, with no other debug text, left me to twiddle around with all other aspects of my application for a few hours before finding out what I have reported here.

Let me know if any further information is needed!

Cheers,
codeape

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions