openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][PHP] Accept headers are discarding content types in favour of application/json

Open Pittiplatsch opened this issue 3 years ago • 2 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [ ] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

What's the point of removing all Accept headers not matching sth. like application/json? ->see HeaderSelector::selectAcceptHeader()

By truncating all but the json content types the endpoint specified in the YAML below isn't reachable: The sunny case (aka HTTP 200) only delivers application/octet-stream -> if requested with Accept: application/json it fails with 406 Not acceptable according to RFC 2616.

I assume to understand the intention of HeaderSelector::selectAcceptHeader(): prioritize application/json as the PHP client only can interpret / deserialize JSON responses. However, there are services which may respond with non-JSON, especially with a plain file which the client can handle as well.

openapi-generator version
  • 4.3.1
  • 5.0.0
  • 6.0.1
OpenAPI declaration file content or url

https://gist.github.com/Pittiplatsch/d345dcdd40027e2ef31fc71213626373

Generation Details

No special configuration needed.

Steps to reproduce

Just generate PHP client according to documentation.

Related issues/PRs

#4684 #5163

Suggest a fix

Maybe some kind of prioritizing via quality values might help? This of course requires the server to interpret them correctly.

Pittiplatsch avatar Jul 19 '22 14:07 Pittiplatsch

This is fixed in #4684, I guess it can be closed? :smile:

thomasphansen avatar Oct 17 '22 14:10 thomasphansen

@wing328, I think I overlooked this one. What @Pittiplatsch is complaining about is deeper than #4684, and I'd like to discuss that with you, if you have the time. It's relevant to the new client I'm writing, Could you please reopen this issue?

thomasphansen avatar Oct 17 '22 20:10 thomasphansen