Added support for datetime query parameters in cpprest (#4556)

* Added support for datetime query parameters in cpprest

Signed-off-by: Gene Chang <gene.chang@anyconnect.com>

* Update petstore sample app for cpprest using bin/cpprest-petstore.sh

Signed-off-by: Gene Chang <gene.chang@anyconnect.com>
This commit is contained in:
Gene Chang
2017-01-13 11:07:06 -05:00
committed by wing328
parent 2e7e25801d
commit 95987fc132
13 changed files with 26 additions and 14 deletions

View File

@@ -38,6 +38,7 @@ public:
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(const utility::datetime &value);
template<class T>
static utility::string_t parameterToArrayString(std::vector<T> value)

View File

@@ -40,6 +40,11 @@ utility::string_t ApiClient::parameterToString(int32_t value)
return utility::conversions::to_string_t(std::to_string(value));
}
utility::string_t ApiClient::parameterToString(const utility::datetime &value)
{
return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601));
}
pplx::task<web::http::http_response> ApiClient::callApi(
const utility::string_t& path,
const utility::string_t& method,

View File

@@ -52,6 +52,11 @@ utility::string_t ApiClient::parameterToString(int32_t value)
return utility::conversions::to_string_t(std::to_string(value));
}
utility::string_t ApiClient::parameterToString(const utility::datetime &value)
{
return utility::conversions::to_string_t(value.to_string(utility::datetime::ISO_8601));
}
pplx::task<web::http::http_response> ApiClient::callApi(
const utility::string_t& path,
const utility::string_t& method,

View File

@@ -50,6 +50,7 @@ public:
static utility::string_t parameterToString(utility::string_t value);
static utility::string_t parameterToString(int32_t value);
static utility::string_t parameterToString(int64_t value);
static utility::string_t parameterToString(const utility::datetime &value);
template<class T>
static utility::string_t parameterToArrayString(std::vector<T> value)

View File

@@ -438,7 +438,7 @@ pplx::task<std::vector<std::shared_ptr<Pet>>> PetApi::findPetsByTags(std::vector
{
queryParams[U("tags")] = ApiClient::parameterToArrayString<utility::string_t>(tags);
queryParams[U("tags")] = ApiClient::parameterToArrayString<>(tags);
}
std::shared_ptr<IHttpBody> httpBody;

View File

@@ -22,10 +22,10 @@
#include "ApiClient.h"
#include "ApiResponse.h"
#include "HttpContent.h"
#include "Pet.h"
#include <cpprest/details/basic_types.h>
#include "ApiResponse.h"
#include "HttpContent.h"
namespace io {
namespace swagger {

View File

@@ -22,9 +22,9 @@
#include "ApiClient.h"
#include "Order.h"
#include <map>
#include <cpprest/details/basic_types.h>
#include <map>
#include "Order.h"
namespace io {
namespace swagger {

View File

@@ -21,7 +21,7 @@ namespace model {
Category::Category()
{
m_Id = 0;
m_Id = 0L;
m_IdIsSet = false;
m_Name = U("");
m_NameIsSet = false;

View File

@@ -21,9 +21,9 @@ namespace model {
Order::Order()
{
m_Id = 0;
m_Id = 0L;
m_IdIsSet = false;
m_PetId = 0;
m_PetId = 0L;
m_PetIdIsSet = false;
m_Quantity = 0;
m_QuantityIsSet = false;

View File

@@ -21,7 +21,7 @@ namespace model {
Pet::Pet()
{
m_Id = 0;
m_Id = 0L;
m_IdIsSet = false;
m_CategoryIsSet = false;
m_Name = U("");

View File

@@ -22,10 +22,10 @@
#include "ModelBase.h"
#include "Category.h"
#include <cpprest/details/basic_types.h>
#include <vector>
#include "Tag.h"
#include <cpprest/details/basic_types.h>
#include "Category.h"
#include <vector>
namespace io {
namespace swagger {

View File

@@ -21,7 +21,7 @@ namespace model {
Tag::Tag()
{
m_Id = 0;
m_Id = 0L;
m_IdIsSet = false;
m_Name = U("");
m_NameIsSet = false;

View File

@@ -21,7 +21,7 @@ namespace model {
User::User()
{
m_Id = 0;
m_Id = 0L;
m_IdIsSet = false;
m_Username = U("");
m_UsernameIsSet = false;