mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
[cpp-restsdk] store Object as a shared pointer (#21349)
* [cpp-restsdk] store Object as a shared pointer * [cpp-restsdk] add test for object property
This commit is contained in:
parent
fa64c8e012
commit
12fa2c0032
@ -387,6 +387,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
|
|||||||
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
|| ModelUtils.isFileSchema(p) || ModelUtils.isUUIDSchema(p)
|
||||||
|| languageSpecificPrimitives.contains(openAPIType)) {
|
|| languageSpecificPrimitives.contains(openAPIType)) {
|
||||||
return toModelName(openAPIType);
|
return toModelName(openAPIType);
|
||||||
|
} else if (ModelUtils.isObjectSchema(p)) {
|
||||||
|
return "std::shared_ptr<Object>";
|
||||||
} else if(typeMapping.containsKey(super.getSchemaType(p))) {
|
} else if(typeMapping.containsKey(super.getSchemaType(p))) {
|
||||||
return openAPIType;
|
return openAPIType;
|
||||||
}
|
}
|
||||||
|
@ -798,6 +798,8 @@ components:
|
|||||||
- available
|
- available
|
||||||
- pending
|
- pending
|
||||||
- sold
|
- sold
|
||||||
|
metadata:
|
||||||
|
type: object
|
||||||
xml:
|
xml:
|
||||||
name: Pet
|
name: Pet
|
||||||
Color:
|
Color:
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "CppRestPetstoreClient/model/Tag.h"
|
#include "CppRestPetstoreClient/model/Tag.h"
|
||||||
#include "CppRestPetstoreClient/model/Category.h"
|
#include "CppRestPetstoreClient/model/Category.h"
|
||||||
#include <cpprest/details/basic_types.h>
|
#include <cpprest/details/basic_types.h>
|
||||||
|
#include "CppRestPetstoreClient/Object.h"
|
||||||
#include "CppRestPetstoreClient/model/Pet.h"
|
#include "CppRestPetstoreClient/model/Pet.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "CppRestPetstoreClient/model/Tag.h"
|
#include "CppRestPetstoreClient/model/Tag.h"
|
||||||
#include "CppRestPetstoreClient/model/Category.h"
|
#include "CppRestPetstoreClient/model/Category.h"
|
||||||
#include <cpprest/details/basic_types.h>
|
#include <cpprest/details/basic_types.h>
|
||||||
|
#include "CppRestPetstoreClient/Object.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace org {
|
namespace org {
|
||||||
@ -109,6 +110,11 @@ public:
|
|||||||
void unsetStatus();
|
void unsetStatus();
|
||||||
void setStatus(const StatusEnum value);
|
void setStatus(const StatusEnum value);
|
||||||
|
|
||||||
|
std::shared_ptr<Object> getMetadata() const;
|
||||||
|
bool metadataIsSet() const;
|
||||||
|
void unsetMetadata();
|
||||||
|
void setMetadata(const std::shared_ptr<Object>& value);
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int64_t m_Id;
|
int64_t m_Id;
|
||||||
@ -129,6 +135,9 @@ protected:
|
|||||||
StatusEnum m_Status;
|
StatusEnum m_Status;
|
||||||
bool m_StatusIsSet;
|
bool m_StatusIsSet;
|
||||||
|
|
||||||
|
std::shared_ptr<Object> m_Metadata;
|
||||||
|
bool m_MetadataIsSet;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ Pet::Pet()
|
|||||||
m_PhotoUrlsIsSet = false;
|
m_PhotoUrlsIsSet = false;
|
||||||
m_TagsIsSet = false;
|
m_TagsIsSet = false;
|
||||||
m_StatusIsSet = false;
|
m_StatusIsSet = false;
|
||||||
|
m_MetadataIsSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pet::~Pet()
|
Pet::~Pet()
|
||||||
@ -74,6 +75,11 @@ web::json::value Pet::toJson() const
|
|||||||
val[utility::conversions::to_string_t(_XPLATSTR("status"))] = ModelBase::toJson(refVal);
|
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;
|
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<Object> refVal_setMetadata;
|
||||||
|
ok &= ModelBase::fromJson(fieldValue, refVal_setMetadata);
|
||||||
|
setMetadata(refVal_setMetadata);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,6 +199,10 @@ void Pet::toMultipart(std::shared_ptr<MultipartFormData> multipart, const utilit
|
|||||||
{
|
{
|
||||||
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("status")), fromStatusEnum(m_Status)));
|
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<MultipartFormData> multipart, const utility::string_t& prefix)
|
bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& prefix)
|
||||||
@ -229,6 +250,12 @@ bool Pet::fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const util
|
|||||||
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("status"))), refVal_setStatus );
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("status"))), refVal_setStatus );
|
||||||
setStatus(toStatusEnum(refVal_setStatus));
|
setStatus(toStatusEnum(refVal_setStatus));
|
||||||
}
|
}
|
||||||
|
if(multipart->hasContent(utility::conversions::to_string_t(_XPLATSTR("metadata"))))
|
||||||
|
{
|
||||||
|
std::shared_ptr<Object> refVal_setMetadata;
|
||||||
|
ok &= ModelBase::fromHttpContent(multipart->getContent(utility::conversions::to_string_t(_XPLATSTR("metadata"))), refVal_setMetadata );
|
||||||
|
setMetadata(refVal_setMetadata);
|
||||||
|
}
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +418,27 @@ void Pet::unsetStatus()
|
|||||||
{
|
{
|
||||||
m_StatusIsSet = false;
|
m_StatusIsSet = false;
|
||||||
}
|
}
|
||||||
|
std::shared_ptr<Object> Pet::getMetadata() const
|
||||||
|
{
|
||||||
|
return m_Metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Pet::setMetadata(const std::shared_ptr<Object>& value)
|
||||||
|
{
|
||||||
|
m_Metadata = value;
|
||||||
|
m_MetadataIsSet = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Pet::metadataIsSet() const
|
||||||
|
{
|
||||||
|
return m_MetadataIsSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pet::unsetMetadata()
|
||||||
|
{
|
||||||
|
m_MetadataIsSet = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user