-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cpprest] Add support for nested vectors (#7820)
* Small fixes to prevent crash when empty json body is provided. * cpprest : Add toJson and toHttpContent array support. * petstore : Run script. * cpprest : Fix toHttpContent function header. * petstore : Run script. * cpprest : Add support for primitive response without enclosing item. * cpprest : Fix spaces. * cpprest : Fix build if bodyParam is optional. * cpprest : Fix vector of vector param. * Small updates to use utf encoding Add * operator for ^required
- Loading branch information
1 parent
3b7230b
commit 73bd24d
Showing
40 changed files
with
155 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.0-SNAPSHOT | ||
2.4.0-SNAPSHOT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
@@ -52,20 +52,8 @@ class ApiClient | |
static utility::string_t parameterToString(int64_t value); | ||
static utility::string_t parameterToString(float value); | ||
static utility::string_t parameterToString(const utility::datetime &value); | ||
|
||
template<class T> | ||
static utility::string_t parameterToArrayString(std::vector<T> value) | ||
{ | ||
utility::stringstream_t ss; | ||
|
||
for( size_t i = 0; i < value.size(); i++) | ||
{ | ||
if( i > 0) ss << utility::conversions::to_string_t(", "); | ||
ss << ApiClient::parameterToString(value[i]); | ||
} | ||
|
||
return ss.str(); | ||
} | ||
static utility::string_t parameterToString(const std::vector<T>& value); | ||
|
||
pplx::task<web::http::http_response> callApi( | ||
const utility::string_t& path, | ||
|
@@ -83,6 +71,20 @@ class ApiClient | |
std::shared_ptr<ApiConfiguration> m_Configuration; | ||
}; | ||
|
||
template<class T> | ||
utility::string_t ApiClient::parameterToString(const std::vector<T>& value) | ||
{ | ||
utility::stringstream_t ss; | ||
|
||
for( size_t i = 0; i < value.size(); i++) | ||
{ | ||
if( i > 0) ss << utility::conversions::to_string_t(", "); | ||
ss << ApiClient::parameterToString(value[i]); | ||
} | ||
|
||
return ss.str(); | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
@@ -26,6 +26,8 @@ | |
#include <cpprest/details/basic_types.h> | ||
#include <cpprest/json.h> | ||
|
||
#include <vector> | ||
|
||
namespace io { | ||
namespace swagger { | ||
namespace client { | ||
|
@@ -53,6 +55,8 @@ class ModelBase | |
static web::json::value toJson( int64_t value ); | ||
static web::json::value toJson( double value ); | ||
static web::json::value toJson( bool value ); | ||
template<class T> | ||
static web::json::value toJson(const std::vector<T>& value); | ||
|
||
static int64_t int64_tFromJson(web::json::value& val); | ||
static int32_t int32_tFromJson(web::json::value& val); | ||
|
@@ -70,6 +74,8 @@ class ModelBase | |
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int32_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); | ||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, int64_t value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); | ||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, double value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); | ||
template <class T> | ||
static std::shared_ptr<HttpContent> toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); | ||
|
||
static int64_t int64_tFromHttpContent(std::shared_ptr<HttpContent> val); | ||
static int32_t int32_tFromHttpContent(std::shared_ptr<HttpContent> val); | ||
|
@@ -86,6 +92,27 @@ class ModelBase | |
static std::shared_ptr<std::istream> fromBase64( const utility::string_t& encoded ); | ||
}; | ||
|
||
template<class T> | ||
web::json::value ModelBase::toJson(const std::vector<T>& value) { | ||
std::vector<web::json::value> ret; | ||
for (auto& x : value) { | ||
ret.push_back(toJson(x)); | ||
} | ||
|
||
return web::json::value::array(ret); | ||
} | ||
|
||
template <class T> | ||
std::shared_ptr<HttpContent> ModelBase::toHttpContent( const utility::string_t& name, const std::vector<T>& value, const utility::string_t& contentType ) { | ||
web::json::value json_array = ModelBase::toJson(value); | ||
std::shared_ptr<HttpContent> content( new HttpContent ); | ||
content->setName( name ); | ||
content->setContentDisposition( utility::conversions::to_string_t("form-data") ); | ||
content->setContentType( contentType ); | ||
content->setData( std::shared_ptr<std::istream>( new std::stringstream( utility::conversions::to_utf8string(json_array.serialize()) ) ) ); | ||
return content; | ||
} | ||
|
||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* OpenAPI spec version: 1.0.0 | ||
* Contact: [email protected] | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator 2.3.0-SNAPSHOT. | ||
* NOTE: This class is auto generated by the swagger code generator 2.4.0-SNAPSHOT. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
Oops, something went wrong.