swagger-api / swagger-api/swagger-client
Wrong accept header when making external reference calls with yaml
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
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'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/resolver.js at the referenced line and reproduce the request using the api1.yaml and api2.yml files from the attached archive. Verify that external YAML references receive an Accept header supporting YAML and that the returned YAML is still parsed correctly in the Swagger UI flow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100