diff --git a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache index 343a2697817..dfadeb0d7b5 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/api-source.mustache @@ -221,9 +221,6 @@ pplx::task<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/r throw ApiException(415, U("{{classname}}->{{operationId}} does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - {{#authMethods}} // authentication ({{name}}) required {{#isApiKey}} diff --git a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache index 59ca1c180f8..cc42f7b8c04 100644 --- a/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache +++ b/modules/swagger-codegen/src/main/resources/cpprest/apiclient-source.mustache @@ -100,10 +100,10 @@ pplx::task ApiClient::callApi( uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } std::stringstream data; - postBody->writeTo(data); + uploadData.writeTo(data); auto bodyString = data.str(); auto length = bodyString.size(); - request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, U("multipart/form-data; boundary=") + uploadData.getBoundary()); } else { diff --git a/samples/client/petstore/cpprest/ApiClient.cpp b/samples/client/petstore/cpprest/ApiClient.cpp index dc53f212966..93824ba4e4b 100644 --- a/samples/client/petstore/cpprest/ApiClient.cpp +++ b/samples/client/petstore/cpprest/ApiClient.cpp @@ -112,10 +112,10 @@ pplx::task ApiClient::callApi( uploadData.add(ModelBase::toHttpContent(kvp.first, kvp.second)); } std::stringstream data; - postBody->writeTo(data); + uploadData.writeTo(data); auto bodyString = data.str(); auto length = bodyString.size(); - request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, contentType); + request.set_body(concurrency::streams::bytestream::open_istream(std::move(bodyString)), length, U("multipart/form-data; boundary=") + uploadData.getBoundary()); } else { diff --git a/samples/client/petstore/cpprest/api/PetApi.cpp b/samples/client/petstore/cpprest/api/PetApi.cpp index 4cb45a80111..96fd6d669f3 100644 --- a/samples/client/petstore/cpprest/api/PetApi.cpp +++ b/samples/client/petstore/cpprest/api/PetApi.cpp @@ -118,9 +118,6 @@ pplx::task PetApi::addPet(std::shared_ptr body) throw ApiException(415, U("PetApi->addPet does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -224,9 +221,6 @@ pplx::task PetApi::deletePet(int64_t petId, utility::string_t apiKey) throw ApiException(415, U("PetApi->deletePet does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -329,9 +323,6 @@ pplx::task>> PetApi::findPetsByStatus(std::vect throw ApiException(415, U("PetApi->findPetsByStatus does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -459,9 +450,6 @@ pplx::task>> PetApi::findPetsByTags(std::vector throw ApiException(415, U("PetApi->findPetsByTags does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -586,9 +574,6 @@ pplx::task> PetApi::getPetById(int64_t petId) throw ApiException(415, U("PetApi->getPetById does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (api_key) required { utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key")); @@ -732,9 +717,6 @@ pplx::task PetApi::updatePet(std::shared_ptr body) throw ApiException(415, U("PetApi->updatePet does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -843,9 +825,6 @@ pplx::task PetApi::updatePetWithForm(int64_t petId, utility::string_t name throw ApiException(415, U("PetApi->updatePetWithForm does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config @@ -953,9 +932,6 @@ pplx::task> PetApi::uploadFile(int64_t petId, utili throw ApiException(415, U("PetApi->uploadFile does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (petstore_auth) required // oauth2 authentication is added automatically as part of the http_client_config diff --git a/samples/client/petstore/cpprest/api/StoreApi.cpp b/samples/client/petstore/cpprest/api/StoreApi.cpp index 0000bd34920..4f897327d6e 100644 --- a/samples/client/petstore/cpprest/api/StoreApi.cpp +++ b/samples/client/petstore/cpprest/api/StoreApi.cpp @@ -98,9 +98,6 @@ pplx::task StoreApi::deleteOrder(utility::string_t orderId) throw ApiException(415, U("StoreApi->deleteOrder does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -196,9 +193,6 @@ pplx::task> StoreApi::getInventory() throw ApiException(415, U("StoreApi->getInventory does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - // authentication (api_key) required { utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key")); @@ -327,9 +321,6 @@ pplx::task> StoreApi::getOrderById(int64_t orderId) throw ApiException(415, U("StoreApi->getOrderById does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -463,9 +454,6 @@ pplx::task> StoreApi::placeOrder(std::shared_ptr b throw ApiException(415, U("StoreApi->placeOrder does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) diff --git a/samples/client/petstore/cpprest/api/UserApi.cpp b/samples/client/petstore/cpprest/api/UserApi.cpp index f3ff28cb2ff..50badbae649 100644 --- a/samples/client/petstore/cpprest/api/UserApi.cpp +++ b/samples/client/petstore/cpprest/api/UserApi.cpp @@ -116,9 +116,6 @@ pplx::task UserApi::createUser(std::shared_ptr body) throw ApiException(415, U("UserApi->createUser does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -241,9 +238,6 @@ pplx::task UserApi::createUsersWithArrayInput(std::vectorcreateUsersWithArrayInput does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -366,9 +360,6 @@ pplx::task UserApi::createUsersWithListInput(std::vectorcreateUsersWithListInput does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("POST"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -466,9 +457,6 @@ pplx::task UserApi::deleteUser(utility::string_t username) throw ApiException(415, U("UserApi->deleteUser does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("DELETE"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -566,9 +554,6 @@ pplx::task> UserApi::getUserByName(utility::string_t usern throw ApiException(415, U("UserApi->getUserByName does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -696,9 +681,6 @@ pplx::task UserApi::loginUser(utility::string_t username, uti throw ApiException(415, U("UserApi->loginUser does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -818,9 +800,6 @@ pplx::task UserApi::logoutUser() throw ApiException(415, U("UserApi->logoutUser does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("GET"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) @@ -937,9 +916,6 @@ pplx::task UserApi::updateUser(utility::string_t username, std::shared_ptr throw ApiException(415, U("UserApi->updateUser does not consume any supported media type")); } - //Set the request content type in the header. - headerParams[U("Content-Type")] = requestHttpContentType; - return m_ApiClient->callApi(path, U("PUT"), queryParams, httpBody, headerParams, formParams, fileParams, requestHttpContentType) .then([=](web::http::http_response response) diff --git a/samples/client/petstore/cpprest/model/Pet.h b/samples/client/petstore/cpprest/model/Pet.h index df26cd36d1c..42e534ae4e1 100644 --- a/samples/client/petstore/cpprest/model/Pet.h +++ b/samples/client/petstore/cpprest/model/Pet.h @@ -22,10 +22,10 @@ #include "ModelBase.h" -#include "Tag.h" -#include #include "Category.h" +#include #include +#include "Tag.h" namespace io { namespace swagger {