Skip to content

Commit cdd5f04

Browse files
committed
[cpp-rest-sdk] support serializing model base as parameters
1 parent fda55b2 commit cdd5f04

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/apiclient-header.mustache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <cpprest/http_client.h>
2525

2626
#include <memory>
27+
#include <map>
2728
#include <vector>
2829
#include <functional>
2930

samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/ApiClient.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <cpprest/http_client.h>
3333

3434
#include <memory>
35+
#include <map>
3536
#include <vector>
3637
#include <functional>
3738

@@ -66,6 +67,8 @@ class ApiClient
6667
static utility::string_t parameterToString(const ModelBase& value);
6768
template<class T>
6869
static utility::string_t parameterToString(const std::vector<T>& value);
70+
template<class T, class U>
71+
static utility::string_t parameterToString(const std::map<T, U>& value);
6972
template<class T>
7073
static utility::string_t parameterToString(const std::shared_ptr<T>& value);
7174

@@ -100,6 +103,19 @@ utility::string_t ApiClient::parameterToString(const std::vector<T>& value)
100103
return ss.str();
101104
}
102105

106+
template<class T, class U>
107+
utility::string_t ApiClient::parameterToString(const std::map<T, U>& value)
108+
{
109+
utility::stringstream_t ss;
110+
ss << "{";
111+
for(const auto& pair : value)
112+
{
113+
ss << ApiClient::parameterToString(pair.first) << ": " << ApiClient::parameterToString(pair.second) << ", ";
114+
}
115+
ss << "}";
116+
return ss.str();
117+
}
118+
103119
template<class T>
104120
utility::string_t ApiClient::parameterToString(const std::shared_ptr<T>& value)
105121
{

0 commit comments

Comments
 (0)