forked from loafle/openapi-generator-original
[CPPREST] Fixed multipart files upload implementation (#6518)
This commit is contained in:
@@ -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}}
|
||||
|
||||
@@ -100,10 +100,10 @@ pplx::task<web::http::http_response> 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
|
||||
{
|
||||
|
||||
@@ -112,10 +112,10 @@ pplx::task<web::http::http_response> 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
|
||||
{
|
||||
|
||||
@@ -118,9 +118,6 @@ pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> 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<void> 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<std::vector<std::shared_ptr<Pet>>> 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<std::vector<std::shared_ptr<Pet>>> 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<std::shared_ptr<Pet>> 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<void> PetApi::updatePet(std::shared_ptr<Pet> 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<void> 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<std::shared_ptr<ApiResponse>> 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
|
||||
|
||||
|
||||
@@ -98,9 +98,6 @@ pplx::task<void> 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<std::map<utility::string_t, int32_t>> 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<std::shared_ptr<Order>> 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<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> 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)
|
||||
|
||||
@@ -116,9 +116,6 @@ pplx::task<void> UserApi::createUser(std::shared_ptr<User> 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<void> UserApi::createUsersWithArrayInput(std::vector<std::shared_ptr<
|
||||
throw ApiException(415, U("UserApi->createUsersWithArrayInput 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<void> UserApi::createUsersWithListInput(std::vector<std::shared_ptr<U
|
||||
throw ApiException(415, U("UserApi->createUsersWithListInput 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<void> 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<std::shared_ptr<User>> 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<utility::string_t> 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<void> 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<void> 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)
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
#include "ModelBase.h"
|
||||
|
||||
#include "Tag.h"
|
||||
#include <cpprest/details/basic_types.h>
|
||||
#include "Category.h"
|
||||
#include <cpprest/details/basic_types.h>
|
||||
#include <vector>
|
||||
#include "Tag.h"
|
||||
|
||||
namespace io {
|
||||
namespace swagger {
|
||||
|
||||
Reference in New Issue
Block a user