Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !10337

Accept header forces application/json type even if server

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/wtrocki/patch-1 into master Sep 06, 2021
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 4

Created by: wtrocki

https://github.com/OpenAPITools/openapi-generator/issues/10340

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. This will crash as the server only knows how to return zip content type.

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

Request is mixed with zip and json on 500:

 ],
        "responses": {
          "200": {
            "content": {
              "application/zip": {
                "schema": {
                  "$ref": "#/components/schemas/FileContent"
                }
              }
            },
            "description": "Response when the export is successful."
          },
          "500": {
            "$ref": "#/components/responses/ServerError"
          }
        },

Headers are generated properly but request is later made with "application/json"

HTTPHeaderAccepts := []string{"application/zip", "application/json"}
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/wtrocki/patch-1