[Java][google-api-client] Fix bug with empty POST request not sending content-type#7787
Merged
wing328 merged 4 commits intoswagger-api:masterfrom Mar 8, 2018
Merged
Conversation
…d fix a bug with collections
Contributor
Author
|
Travis failed on some unrelated Python thing, I'm guessing this is a known issue: |
Contributor
|
The Travis build error is likely due to a change in the build image. I'll look into it tomorrow. Thanks for the fix. |
Contributor
Author
|
Thanks @wing328 ! |
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.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.shand./bin/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.3.0.0branch for changes related to OpenAPI spec 3.0. Default:master.Java technical committee - @bbdouglas (2017/07) @JFCote (2017/08) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01)
Description of the PR
Fixes #7786
This PR basically fixes a few issues with the
google-api-clienttemplates.The biggest issue is POST requests for endpoints that send empty request bodies are failing with a 415 status code (Unsupported Media Type) because the
Content-Type: application/jsonisn't being sent in this case.A good example would be -- in our APIs we have lifecycle operations such as
POST /foo/{id}/publishorPOST /foo/{id}/pausewhich transition some entity to a different state, but no request body is required since we are simply indicating that apublishis taking place.This PR also fixes a few random issues with the templates:
List<String>orList<Object>of any kind.Object[]to theUriBuilderin the generated code.java.io.InputStreamas the request body.text/csvtype).Test Plan
./bin/java-petstore-google-api-client.shmvn clean testin thesamples/client/petstore/java/google-api-clientdirectory and it succeededgoogle-api-clientclient for a complex API with the new codegen code. I have verified that empty POST requests now work, list query params now work, and input streams work for the request body if the overloaded method is used.