mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-20 09:47:11 +00:00
* Fixed cpprest generator to include Content-Type header in requests. * Fixing indent to use spaces.
This commit is contained in:
@@ -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
|
||||
@@ -39,12 +39,6 @@ PetApi::~PetApi()
|
||||
pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> body)
|
||||
{
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == nullptr)
|
||||
{
|
||||
throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->addPet"));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/pet");
|
||||
@@ -55,13 +49,18 @@ pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> body)
|
||||
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");
|
||||
}
|
||||
@@ -118,7 +117,10 @@ consumeHttpContentTypes.insert( U("application/xml") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -171,13 +173,18 @@ pplx::task<void> PetApi::deletePet(int64_t petId, utility::string_t apiKey)
|
||||
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");
|
||||
}
|
||||
@@ -224,7 +231,10 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -276,13 +286,18 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vect
|
||||
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");
|
||||
}
|
||||
@@ -325,7 +340,10 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -403,13 +421,18 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector
|
||||
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");
|
||||
}
|
||||
@@ -429,7 +452,7 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
|
||||
|
||||
{
|
||||
queryParams[U("tags")] = ApiClient::parameterToArrayString<>(tags);
|
||||
queryParams[U("tags")] = ApiClient::parameterToArrayString<utility::string_t>(tags);
|
||||
|
||||
}
|
||||
|
||||
@@ -452,7 +475,10 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -531,13 +557,18 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId)
|
||||
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");
|
||||
}
|
||||
@@ -579,8 +610,13 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
else
|
||||
{
|
||||
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 (petstore_auth) required
|
||||
// oauth2 authentication is added automatically as part of the http_client_config
|
||||
// authentication (api_key) required
|
||||
{
|
||||
utility::string_t apiKey = apiConfiguration->getApiKey(U("api_key"));
|
||||
@@ -645,12 +681,6 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> body)
|
||||
{
|
||||
|
||||
// verify the required parameter 'body' is set
|
||||
if (body == nullptr)
|
||||
{
|
||||
throw ApiException(400, U("Missing required parameter 'body' when calling PetApi->updatePet"));
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
|
||||
utility::string_t path = U("/pet");
|
||||
@@ -661,13 +691,18 @@ pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> body)
|
||||
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");
|
||||
}
|
||||
@@ -724,7 +759,10 @@ consumeHttpContentTypes.insert( U("application/xml") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -763,7 +801,7 @@ consumeHttpContentTypes.insert( U("application/xml") );
|
||||
return void();
|
||||
});
|
||||
}
|
||||
pplx::task<void> PetApi::updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status)
|
||||
pplx::task<void> PetApi::updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status)
|
||||
{
|
||||
|
||||
|
||||
@@ -777,13 +815,18 @@ pplx::task<void> PetApi::updatePetWithForm(int64_t petId, utility::string_t name
|
||||
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");
|
||||
}
|
||||
@@ -836,7 +879,10 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -875,7 +921,7 @@ responseHttpContentTypes.insert( U("application/json") );
|
||||
return void();
|
||||
});
|
||||
}
|
||||
pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr<HttpContent> file)
|
||||
pplx::task<void> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr<HttpContent> file)
|
||||
{
|
||||
|
||||
|
||||
@@ -890,11 +936,17 @@ pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, utili
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -947,7 +999,10 @@ pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, utili
|
||||
else
|
||||
{
|
||||
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
|
||||
@@ -983,26 +1038,8 @@ pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, utili
|
||||
})
|
||||
.then([=](utility::string_t response)
|
||||
{
|
||||
std::shared_ptr<ApiResponse> result(new ApiResponse());
|
||||
|
||||
if(responseHttpContentType == U("application/json"))
|
||||
{
|
||||
web::json::value json = web::json::value::parse(response);
|
||||
|
||||
result->fromJson(json);
|
||||
}
|
||||
// else if(responseHttpContentType == U("multipart/form-data"))
|
||||
// {
|
||||
// TODO multipart response parsing
|
||||
// }
|
||||
else
|
||||
{
|
||||
throw ApiException(500
|
||||
, U("error calling findPetsByStatus: unsupported response type"));
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
return void();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user