OpenAPITools / OpenAPITools/openapi-generator
[BUG][Go] Content type selection breaks when multiple content types present
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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
When API returns mixed content - 200 returns File/Binary and 500 returns JSON which is typical for error handling.
Generated code will include two accept headers. Problem is that selectHeaderAccept function that builds headers always forces accept headers to be JSON. As result server responses crash as server only knows how to set zip content type.
HTTPHeaderAccepts := []string{"application/zip", "application/json"}
openapi-generator version
5.2.1
OpenAPI declaration file content or URL
Steps to reproduce
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/pull/10337
Suggest a fix
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 the generated registryinstance/apiv1internal/client/api_admin.go selectHeaderAccept call and compare it with the content definitions in .openapi/registry-instance.json. Review related pull request 10337 for existing context, then trace the corresponding OpenAPI Generator logic. Done means generated Go clients handle the mixed binary and JSON responses without forcing the wrong content type, with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100