OpenAPITools / OpenAPITools/openapi-generator

[BUG][Go] Content type selection breaks when multiple content types present

Open
#10,340 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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.

https://github.com/redhat-developer/app-services-sdk-go/blob/main/registryinstance/apiv1internal/client/api_admin.go#L1004-L1007

HTTPHeaderAccepts := []string{"application/zip", "application/json"}
openapi-generator version

5.2.1

OpenAPI declaration file content or URL

https://github.com/redhat-developer/app-services-sdk-go/blob/main/.openapi/registry-instance.json#L651-L665

Steps to reproduce
Related issues/PRs

https://github.com/OpenAPITools/openapi-generator/pull/10337

Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.