Accept header forces application/json type even if server #10337
Accept header forces application/json type even if server #10337wing328 merged 2 commits intoOpenAPITools:masterfrom
Conversation
|
Can you please follow step 3 in the PR checklist to update the samples so that the CI can verify the change? https://github.com/OpenAPITools/openapi-generator/blob/master/.github/PULL_REQUEST_TEMPLATE.md cc @antihax (2017/11) @grokify (2018/07) @kemokemo (2018/09) @jirikuncar (2021/01) @ph4r5h4d (2021/04) |
Generated code offen provides range of accept methods.
This method improperly takes JSON as preferred
Example:
localVarHTTPHeaderAccepts := []string{"application/zip", "application/json"}
|
Rebased. Updated samples. Verified. |
|
Looks like this breaks the CI so I've to revert the change via #10440 For the error log, please refer to https://app.circleci.com/pipelines/github/OpenAPITools/openapi-generator/12853/workflows/ae655d09-315f-43ae-9669-ac2379d0a964/jobs/26495 To run the Go Petstore tests, please refer to https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests#how-to-add-integration-tests-for-new-petstore-samples on how to run the test server locally. |
#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:
Headers are generated properly but request is later made with "application/json"