2

I'm attempting to add swagger as part of a locally developed project, but I'm finding that when I use the petstore example, requests incorrectly sends 'Accept: text/html' instead of the expected 'Accept: application/json', as specified in the petstore schema.

After banging my head against a wall, I realized that this issue seems to occur whenever you are running the swagger client on the same host (in this case, 'localhost') as the web services you are trying to call. If I change the web services to another port, it works just fine and sends application/json as expected (although this results in the expected CORS issues).

What gives? I'd expect the same headers to be sent whether the swagger ui client was accessing local or remote web services. Is this a bug or am I missing something obvious?

agoldencom
  • 1,196
  • 1
  • 8
  • 13
  • Have you ensured that you've set the `produces: application/json` in your swagger definition? – fehguy Mar 14 '16 at 17:27
  • Yes, even when produces / consumes is explicitly noted, it sends an 'Accept: text/html' if the target is the same server (i.e., localhost in this instance) – agoldencom Mar 15 '16 at 15:03
  • Please share your swagger-definition and I can help. Best shared in a gist or in a ticket in swagger-ui repo. – fehguy Mar 16 '16 at 14:40

0 Answers0