api
api copied to clipboard
Allow Accept headers to be sent regardless if they're defined in the OAS
This should resolve the issue brought up in https://github.com/readmeio/api/pull/447. Basically if an Accept header isn't defined in a paths parameters block we currently don't allow you to supply it in the metadata argument. Because Accept headers defined in parameters should actually be ignored (per the spec) we should instead do a couple things:
- [ ] If a path has
responses(optional in OpenAPI 3.1) andresponses.*.contentpresent we should default to sending anAcceptheader for whichever media type is JSON-compatible. - [ ] If no media type in the response content is JSON-compatible we should pick the first and send that.
- [ ] We should also not do
res.json()when returning the response as that'll throw JSON parsing errors.
- [ ] We should also not do
- [ ] If an
Acceptheader is present inmetadata, allow it through regardless if its value matches a media type inresponses.*.content.
Hey @erunion, will this enhancement make it into v5?
@bennycode Yeah I'm planning on digging into this starting Monday.