api icon indicating copy to clipboard operation
api copied to clipboard

Allow Accept headers to be sent regardless if they're defined in the OAS

Open erunion opened this issue 3 years ago • 2 comments

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) and responses.*.content present we should default to sending an Accept header 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.
  • [ ] If an Accept header is present in metadata, allow it through regardless if its value matches a media type in responses.*.content.

erunion avatar May 25 '22 16:05 erunion

Hey @erunion, will this enhancement make it into v5?

bennycode avatar Oct 15 '22 13:10 bennycode

@bennycode Yeah I'm planning on digging into this starting Monday.

erunion avatar Oct 15 '22 15:10 erunion