update cpprest petstore sample

This commit is contained in:
wing328
2017-05-05 16:20:59 +08:00
parent 8e6dfce83e
commit 8e0d940e0a
32 changed files with 159 additions and 114 deletions

View File

@@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@@ -39,6 +39,12 @@ 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");
@@ -49,8 +55,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -166,8 +172,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -271,8 +277,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -401,8 +407,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -532,8 +538,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -583,8 +589,6 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId)
//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"));
@@ -649,6 +653,12 @@ pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId)
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");
@@ -659,8 +669,8 @@ 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/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -762,7 +772,7 @@ pplx::task<void> PetApi::updatePet(std::shared_ptr<Pet> body)
return void();
});
}
pplx::task<void> PetApi::updatePetWithForm(utility::string_t petId, utility::string_t name, utility::string_t status)
pplx::task<void> PetApi::updatePetWithForm(int64_t petId, utility::string_t name, utility::string_t status)
{
@@ -776,8 +786,8 @@ pplx::task<void> PetApi::updatePetWithForm(utility::string_t petId, utility::str
std::map<utility::string_t, std::shared_ptr<HttpContent>> fileParams;
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
responseHttpContentTypes.insert( U("application/json") );
utility::string_t responseHttpContentType;
@@ -873,7 +883,7 @@ pplx::task<void> PetApi::updatePetWithForm(utility::string_t petId, utility::str
return void();
});
}
pplx::task<void> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr<HttpContent> file)
pplx::task<std::shared_ptr<ApiResponse>> PetApi::uploadFile(int64_t petId, utility::string_t additionalMetadata, std::shared_ptr<HttpContent> file)
{
@@ -888,7 +898,6 @@ pplx::task<void> PetApi::uploadFile(int64_t petId, utility::string_t additionalM
std::unordered_set<utility::string_t> responseHttpContentTypes;
responseHttpContentTypes.insert( U("application/json") );
responseHttpContentTypes.insert( U("application/xml") );
utility::string_t responseHttpContentType;
@@ -981,7 +990,25 @@ pplx::task<void> PetApi::uploadFile(int64_t petId, utility::string_t additionalM
})
.then([=](utility::string_t response)
{
return void();
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 uploadFile: unsupported response type"));
}
return result;
});
}