Description
In the client support I added for google-api-client, there are a few minor bugs needing fixing.
- Empty POST requests can fail because it doesn't send the Content-Type
- Query params aren't used correctly if they are
List<String> type
- Support
InputStream type for the request body; highly useful for proxy services
Swagger-codegen version
2.3.1 (I hope to eventually port these templates to Swagger 3.0.0).
Swagger declaration file content or url
n/a - this really depends on how the server is configured to require the Content-Type header, but here is an example snippet of the endpoint that was failing and takes an empty POST request:
"/forms/{id}/publish" : {
"post" : {
"tags" : [ "Forms" ],
"summary" : "Publish a Form",
"description" : "",
"operationId" : "publishForm",
"consumes" : [ "application/json" ],
"produces" : [ "application/json" ],
"parameters" : [ {
"name" : "id",
"in" : "path",
"required" : true,
"type" : "integer",
"format" : "int64"
} ],
"responses" : {
"200" : {
"description" : "successful operation",
"schema" : {
"$ref" : "#/definitions/Form"
}
}
}
}
}
Command line used for generation
config.json
{
"library": "google-api-client",
"artifactId": "${CLIENT_LIB_ARTIFACT_ID}",
"groupId": "${SERVICE_GROUP_ID}",
"artifactVersion": "${SERVICE_VERSION}"
}
# Generate the code!
java -jar swagger-codegen-cli-2.3.1.jar \
generate -i swagger.json \
-l java \
-o ${SWAGGER_BUILD_DIR} \
-c config.json \
--api-package "${CLIENT_LIB_PACKAGE}.api" \
--model-package "${CLIENT_LIB_PACKAGE}.model" \
--invoker-package ${CLIENT_LIB_PACKAGE}
Steps to reproduce
Use the swagger client to contact an endpoint that takes no request body (empty POST) but the JAX-RS annotations are configured with @Consumes({"application/json"}) so that a content-type must be set.
Result: get a 415 : Unsupported media type error.
Related issues/PRs
#6825
#6838
Suggest a fix/enhancement
I'm fixing it! About to put up a pull request.
Description
In the client support I added for
google-api-client, there are a few minor bugs needing fixing.List<String>typeInputStreamtype for the request body; highly useful for proxy servicesSwagger-codegen version
2.3.1 (I hope to eventually port these templates to Swagger 3.0.0).
Swagger declaration file content or url
n/a - this really depends on how the server is configured to require the
Content-Typeheader, but here is an example snippet of the endpoint that was failing and takes an empty POST request:Command line used for generation
config.json{ "library": "google-api-client", "artifactId": "${CLIENT_LIB_ARTIFACT_ID}", "groupId": "${SERVICE_GROUP_ID}", "artifactVersion": "${SERVICE_VERSION}" }Steps to reproduce
Use the swagger client to contact an endpoint that takes no request body (empty POST) but the JAX-RS annotations are configured with
@Consumes({"application/json"})so that a content-type must be set.Result: get a
415 : Unsupported media typeerror.Related issues/PRs
#6825
#6838
Suggest a fix/enhancement
I'm fixing it! About to put up a pull request.