diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache index 041cd1838821..5fb44a81fae3 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-header.mustache @@ -64,6 +64,7 @@ public: static web::json::value toJson( const std::shared_ptr& val ); template static web::json::value toJson( const std::shared_ptr& val ); + static web::json::value toJson( const std::shared_ptr& val ); template static web::json::value toJson( const std::vector& val ); template @@ -80,6 +81,7 @@ public: static bool fromString( const utility::string_t& val, std::shared_ptr & ); template static bool fromString( const utility::string_t& val, std::shared_ptr& ); + static bool fromString( const utility::string_t& val, std::shared_ptr& outVal ); template static bool fromString( const utility::string_t& val, std::vector & ); template @@ -96,6 +98,7 @@ public: static bool fromJson( const web::json::value& val, std::shared_ptr & ); template static bool fromJson( const web::json::value& val, std::shared_ptr& ); + static bool fromJson( const web::json::value& val, std::shared_ptr &outVal ); template static bool fromJson( const web::json::value& val, std::vector & ); template @@ -113,6 +116,7 @@ public: static std::shared_ptr toHttpContent( const utility::string_t& name, const std::shared_ptr& ); template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::shared_ptr& , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); + static std::shared_ptr toHttpContent(const utility::string_t& name, const std::shared_ptr& value , const utility::string_t& contentType = utility::conversions::to_string_t("application/json") ); template static std::shared_ptr toHttpContent( const utility::string_t& name, const std::vector& value, const utility::string_t& contentType = utility::conversions::to_string_t("") ); template diff --git a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache index 976a9733209e..752834303249 100644 --- a/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-rest-sdk-client/modelbase-source.mustache @@ -112,6 +112,15 @@ web::json::value ModelBase::toJson( const std::shared_ptr& content } return value; } +web::json::value ModelBase::toJson( const std::shared_ptr& val ) +{ + web::json::value retVal; + if(val != nullptr) + { + retVal = toJson(*val); + } + return retVal; +} bool ModelBase::fromString( const utility::string_t& val, bool &outVal ) { utility::stringstream_t ss(val); @@ -242,6 +251,19 @@ bool ModelBase::fromString( const utility::string_t& val, std::shared_ptr& outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new utility::datetime()); + } + if( outVal != nullptr ) + { + ok = fromJson(web::json::value::parse(val), *outVal); + } + return ok; +} bool ModelBase::fromJson( const web::json::value& val, bool & outVal ) { outVal = !val.is_boolean() ? false : val.as_bool(); @@ -319,6 +341,19 @@ bool ModelBase::fromJson( const web::json::value& val, std::shared_ptr &outVal ) +{ + bool ok = false; + if(outVal == nullptr) + { + outVal = std::shared_ptr(new utility::datetime()); + } + if( outVal != nullptr ) + { + ok = fromJson(val, *outVal); + } + return ok; +} std::shared_ptr ModelBase::toHttpContent( const utility::string_t& name, bool value, const utility::string_t& contentType ) { std::shared_ptr content( new HttpContent ); @@ -414,6 +449,18 @@ std::shared_ptr ModelBase::toHttpContent( const utility::string_t& } return content; } +std::shared_ptr ModelBase::toHttpContent(const utility::string_t& name, const std::shared_ptr& value , const utility::string_t& contentType ) +{ + std::shared_ptr content( new HttpContent ); + if (value != nullptr ) + { + content->setName( name ); + content->setContentDisposition( utility::conversions::to_string_t("form-data") ); + content->setContentType( contentType ); + content->setData( std::shared_ptr( new std::stringstream( utility::conversions::to_utf8string( toJson(*value).serialize() ) ) ) ); + } + return content; +} bool ModelBase::fromHttpContent(std::shared_ptr val, bool & outVal ) { utility::string_t str;