Accept header forces application/json type even if server #10337
Merged
wing328 merged 2 commits intoOpenAPITools:masterfrom Sep 21, 2021
Merged
Accept header forces application/json type even if server #10337wing328 merged 2 commits intoOpenAPITools:masterfrom
wing328 merged 2 commits intoOpenAPITools:masterfrom
Conversation
6 tasks
Member
|
Can you please follow step 3 in the PR checklist to update the samples so that the CI can verify the change? 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"}
Contributor
Author
|
Rebased. Updated samples. Verified. |
jirikuncar
approved these changes
Sep 17, 2021
Member
|
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. |
wing328
added a commit
that referenced
this pull request
Sep 21, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#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"