diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java index f456c27bd3c..56b3d87f6f7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestSdkClientCodegen.java @@ -387,6 +387,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen { || ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p) || languageSpecificPrimitives.contains(openAPIType)) { return toModelName(openAPIType); + } else if (ModelUtils.isObjectSchema(p)) { + return "std::shared_ptr"; } else if(typeMapping.containsKey(super.getSchemaType(p))) { return openAPIType; } diff --git a/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml b/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml index e28e1c61039..deafefce841 100644 --- a/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml +++ b/modules/openapi-generator/src/test/resources/3_0/cpp-restsdk/petstore.yaml @@ -798,6 +798,8 @@ components: - available - pending - sold + metadata: + type: object xml: name: Pet Color: diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h index 39d63c6b2cf..b1be110bba0 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/CreateUserOrPet_request.h @@ -27,6 +27,7 @@ #include "CppRestPetstoreClient/model/Tag.h" #include "CppRestPetstoreClient/model/Category.h" #include +#include "CppRestPetstoreClient/Object.h" #include "CppRestPetstoreClient/model/Pet.h" #include diff --git a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h index 51e0f5da731..92f25d7f2d7 100644 --- a/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h +++ b/samples/client/petstore/cpp-restsdk/client/include/CppRestPetstoreClient/model/Pet.h @@ -25,6 +25,7 @@ #include "CppRestPetstoreClient/model/Tag.h" #include "CppRestPetstoreClient/model/Category.h" #include +#include "CppRestPetstoreClient/Object.h" #include namespace org { @@ -109,6 +110,11 @@ public: void unsetStatus(); void setStatus(const StatusEnum value); + std::shared_ptr getMetadata() const; + bool metadataIsSet() const; + void unsetMetadata(); + void setMetadata(const std::shared_ptr& value); + protected: int64_t m_Id; @@ -129,6 +135,9 @@ protected: StatusEnum m_Status; bool m_StatusIsSet; + std::shared_ptr m_Metadata; + bool m_MetadataIsSet; + }; diff --git a/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp b/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp index d8226b496ec..114e12306d4 100644 --- a/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp +++ b/samples/client/petstore/cpp-restsdk/client/src/model/Pet.cpp @@ -28,6 +28,7 @@ Pet::Pet() m_PhotoUrlsIsSet = false; m_TagsIsSet = false; m_StatusIsSet = false; + m_MetadataIsSet = false; } Pet::~Pet() @@ -74,6 +75,11 @@ web::json::value Pet::toJson() const val[utility::conversions::to_string_t(_XPLATSTR("status"))] = ModelBase::toJson(refVal); } + if(m_MetadataIsSet) + { + + val[utility::conversions::to_string_t(_XPLATSTR("metadata"))] = ModelBase::toJson(m_Metadata); + } return val; } @@ -148,6 +154,17 @@ bool Pet::fromJson(const web::json::value& val) } } + if(val.has_field(utility::conversions::to_string_t(_XPLATSTR("metadata")))) + { + const web::json::value& fieldValue = val.at(utility::conversions::to_string_t(_XPLATSTR("metadata"))); + if(!fieldValue.is_null()) + { + std::shared_ptr refVal_setMetadata; + ok &= ModelBase::fromJson(fieldValue, refVal_setMetadata); + setMetadata(refVal_setMetadata); + + } + } return ok; } @@ -182,6 +199,10 @@ void Pet::toMultipart(std::shared_ptr multipart, const utilit { multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("status")), fromStatusEnum(m_Status))); } + if(m_MetadataIsSet) + { + multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("metadata")), m_Metadata)); + } } bool Pet::fromMultiPart(std::shared_ptr multipart, const utility::string_t& prefix) @@ -229,6 +250,12 @@ bool Pet::fromMultiPart(std::shared_ptr multipart, const util ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("status"))), refVal_setStatus ); setStatus(toStatusEnum(refVal_setStatus)); } + if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("metadata")))) + { + std::shared_ptr refVal_setMetadata; + ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("metadata"))), refVal_setMetadata ); + setMetadata(refVal_setMetadata); + } return ok; } @@ -391,6 +418,27 @@ void Pet::unsetStatus() { m_StatusIsSet = false; } +std::shared_ptr Pet::getMetadata() const +{ + return m_Metadata; +} + + +void Pet::setMetadata(const std::shared_ptr& value) +{ + m_Metadata = value; + m_MetadataIsSet = true; +} + +bool Pet::metadataIsSet() const +{ + return m_MetadataIsSet; +} + +void Pet::unsetMetadata() +{ + m_MetadataIsSet = false; +} } }