Skip to content

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

Description

@Pittiplatsch

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions