swagger-js icon indicating copy to clipboard operation
swagger-js copied to clipboard

Wrong accept header when making external reference calls with yaml

Open markdemich opened this issue 6 years ago • 0 comments

Q&A (please complete the following information)

  • OS: Windows 10
  • Environment: Chrome Version 76.0.3809.100
  • Method of installation: CDN
  • Swagger-Client version: 3.9.2
  • Swagger/OpenAPI version: OpenAPI 3.0

This zip contains two yaml files. api1.yaml and api2.yml.

Open api1.yaml and then expand the GET box for /test-api-1 If you are serving up these files on a webserver, you'll notice the accept header in the request is application/json.

This causes my IIS server to return an error since it associates *.yaml with application/yaml.

If if I associate *.yaml with application/json (which is a hack), then swagger will still complain because it will get a content-type response of application/json and then not be able to parse the yaml which it thinks is json.

The fix is very easy, we just need to change this line https://github.com/swagger-api/swagger-js/blob/master/src/resolver.js#L16

to

Accept: 'application/json, application/yaml'

markdemich avatar Aug 08 '19 13:08 markdemich