Fix for issue #4370 - Cpprest does not set Content-Type header on POST requests. (#4374)

* Fixed cpprest generator to include Content-Type header in requests.

* Fixing indent to use spaces.
This commit is contained in:
Scott Richter
2016-12-13 02:01:48 -05:00
committed by wing328
parent 15a84259aa
commit da9d64d053
32 changed files with 349 additions and 222 deletions

View File

@@ -1,9 +1,9 @@
/**
* Swagger Petstore
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@@ -50,13 +50,18 @@ pplx::task<void> StoreApi::deleteOrder(utility::string_t orderId)
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
utility::string_t responseHttpContentType;
// use JSON if possible
if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
if ( responseHttpContentTypes.size() == 0 )
{
responseHttpContentType = U("application/json");
}
// JSON
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
{
responseHttpContentType = U("application/json");
}
@@ -98,7 +103,10 @@ responseHttpContentTypes.insert( U("application/json") );
else
{
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)
@@ -149,11 +157,17 @@ pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory()
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
utility::string_t responseHttpContentType;
// use JSON if possible
if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
if ( responseHttpContentTypes.size() == 0 )
{
responseHttpContentType = U("application/json");
}
// JSON
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
{
responseHttpContentType = U("application/json");
}
@@ -191,7 +205,10 @@ pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory()
else
{
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
{
@@ -260,7 +277,7 @@ pplx::task<std::map<utility::string_t, int32_t>> StoreApi::getInventory()
return result;
});
}
pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId)
pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(utility::string_t orderId)
{
@@ -274,13 +291,18 @@ pplx::task<std::shared_ptr<Order>> StoreApi::getOrderById(int64_t orderId)
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
utility::string_t responseHttpContentType;
// use JSON if possible
if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
if ( responseHttpContentTypes.size() == 0 )
{
responseHttpContentType = U("application/json");
}
// JSON
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
{
responseHttpContentType = U("application/json");
}
@@ -322,7 +344,10 @@ responseHttpContentTypes.insert( U("application/json") );
else
{
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)
@@ -380,12 +405,6 @@ responseHttpContentTypes.insert( U("application/json") );
pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> body)
{
// verify the required parameter 'body' is set
if (body == nullptr)
{
throw ApiException(400, U("Missing required parameter 'body' when calling StoreApi->placeOrder"));
}
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/store/order");
@@ -396,13 +415,18 @@ pplx::task<std::shared_ptr<Order>> StoreApi::placeOrder(std::shared_ptr<Order> b
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
utility::string_t responseHttpContentType;
// use JSON if possible
if ( responseHttpContentTypes.size() == 0 || responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
if ( responseHttpContentTypes.size() == 0 )
{
responseHttpContentType = U("application/json");
}
// JSON
else if ( responseHttpContentTypes.find(U("application/json")) != responseHttpContentTypes.end() )
{
responseHttpContentType = U("application/json");
}
@@ -457,7 +481,10 @@ responseHttpContentTypes.insert( U("application/json") );
else
{
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)