Swagger Codegen - Content Type for GET not getting set in Spring-MVC generated

Michael H picture Michael H · Nov 4, 2015 · Viewed 8k times · Source

Downloaded Swagger Pet Store (Simple) from swagger.io editor page and did a mvn jetty:run

When opening up DevTools on Chrome and exercising a GET, I don't see the header Content-Type field being set.

This is on the GET /pets{id}

screen capture

Answer

Michael H picture Michael H · Nov 5, 2015

OK, found the root cause of this problem thanks to wing328 on the swagger codegen project on github.

It turns out that at the top of our yaml definition file we have:

consumes:
 - application/json

That causes all generated controller methods to expect application/json on content-type. This breaks GET, DELETE, and PATCH api calls which in our case do not have any payload.