remove trailing space in cpprest, update samples

This commit is contained in:
wing328
2017-04-24 22:45:16 +08:00
parent fc2b3d49ea
commit aa85468932
32 changed files with 217 additions and 139 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
@@ -38,7 +38,13 @@ 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;
@@ -154,7 +160,7 @@ pplx::task<void> PetApi::addPet(std::shared_ptr<Pet> body)
}
pplx::task<void> PetApi::deletePet(int64_t petId, utility::string_t apiKey)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/{petId}");
@@ -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;
@@ -260,7 +266,7 @@ pplx::task<void> PetApi::deletePet(int64_t petId, utility::string_t apiKey)
}
pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vector<utility::string_t> status)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/findByStatus");
@@ -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;
@@ -390,7 +396,7 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByStatus(std::vect
}
pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector<utility::string_t> tags)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/findByTags");
@@ -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;
@@ -520,7 +526,7 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector
}
pplx::task<std::shared_ptr<Pet>> PetApi::getPetById(int64_t petId)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/{petId}");
@@ -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"));
@@ -648,7 +652,13 @@ 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,9 +772,9 @@ 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)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/{petId}");
@@ -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,9 +883,9 @@ 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)
{
std::shared_ptr<ApiConfiguration> apiConfiguration( m_ApiClient->getConfiguration() );
utility::string_t path = U("/pet/{petId}/uploadImage");
@@ -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;
});
}