Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <variant>
{{/-first}}
{{/oneOf}}
#include <boost/optional.hpp>
{{^parent}}
{{{defaultInclude}}}
#include "{{packageName}}/ModelBase.h"
Expand Down Expand Up @@ -264,13 +265,23 @@ public:
protected:
{{#vars}}
{{^isInherited}}
{{#isNullable}}
{{^isEnum}}
boost::optional<{{{dataType}}}> m_{{name}};
{{/isEnum}}
{{#isEnum}}
boost::optional<{{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}}> m_{{name}};
{{/isEnum}}
{{/isNullable}}
{{^isNullable}}
{{^isEnum}}
{{{dataType}}} m_{{name}};
{{/isEnum}}
{{#isEnum}}
{{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}} m_{{name}};
{{/isEnum}}
bool m_{{name}}IsSet;
{{/isNullable}}
{{/isInherited}}

{{/vars}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} const value)
{
{{#vars}}
{{^isInherited}}
{{^isNullable}}
{{^isContainer}}
{{^isEnum}}
{{#isPrimitiveType}}
Expand All @@ -203,6 +204,7 @@ void {{classname}}::setValue({{classname}}::e{{classname}} const value)
{{/isEnum}}
{{/isContainer}}
m_{{name}}IsSet = false;
{{/isNullable}}
{{/isInherited}}
{{/vars}}
}
Expand All @@ -226,8 +228,25 @@ web::json::value {{classname}}::toJson() const
{{/parent}}
{{#vars}}
{{^isInherited}}
{{#isNullable}}
if(m_{{name}}.has_value())
{
{{#isEnum}}{{#isContainer}}{{#isArray}}
{{{dataType}}} refVal = from{{{enumName}}}(m_{{name}}.get());
{{/isArray}}{{#isMap}}
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}}.get());
{{/isMap}}{{/isContainer}}{{^isContainer}}
utility::string_t refVal = from{{{datatypeWithEnum}}}(m_{{name}}.get());
{{/isContainer}}{{^isMap}}val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(refVal);
{{/isMap}}{{/isEnum}}
{{^isEnum}}
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}}.get());
{{/isEnum}}
}
{{/isNullable}}
{{^isNullable}}
if(m_{{name}}IsSet)
{
{
{{#isEnum}}{{#isContainer}}{{#isArray}}
{{{dataType}}} refVal = from{{{enumName}}}(m_{{name}});
{{/isArray}}{{#isMap}}
Expand All @@ -240,6 +259,7 @@ web::json::value {{classname}}::toJson() const
val[utility::conversions::to_string_t(_XPLATSTR("{{baseName}}"))] = ModelBase::toJson(m_{{name}});
{{/isEnum}}
}
{{/isNullable}}
{{/isInherited}}
{{/vars}}

Expand Down Expand Up @@ -286,6 +306,27 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
namePrefix += utility::conversions::to_string_t(_XPLATSTR("."));
}
{{#vars}}
{{#isNullable}}
if(m_{{name}}.has_value())
{
{{^isEnum}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}.get()));
{{/isEnum}}
{{#isEnum}}
{{#isContainer}}
{{#isArray}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{enumName}}}(m_{{name}}.get())));
{{/isArray}}{{#isMap}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), m_{{name}}.get()));
{{/isMap}}
{{/isContainer}}
{{^isContainer}}
multipart->add(ModelBase::toHttpContent(namePrefix + utility::conversions::to_string_t(_XPLATSTR("{{baseName}}")), from{{{datatypeWithEnum}}}(m_{{name}}.get())));
{{/isContainer}}
{{/isEnum}}
}
{{/isNullable}}
{{^isNullable}}
if(m_{{name}}IsSet)
{
{{^isEnum}}
Expand All @@ -304,6 +345,7 @@ void {{classname}}::toMultipart(std::shared_ptr<MultipartFormData> multipart, co
{{/isContainer}}
{{/isEnum}}
}
{{/isNullable}}
{{/vars}}
}

Expand Down Expand Up @@ -405,22 +447,37 @@ const {{dataType}} {{classname}}::from{{{datatypeWithEnum}}}(const {{{datatypeWi
{{^isEnum}}
{{{dataType}}} {{classname}}::{{getter}}() const
{
{{#isNullable}}
return m_{{name}}.get();
{{/isNullable}}
{{^isNullable}}
return m_{{name}};
{{/isNullable}}
}
{{/isEnum}}
{{/isContainer}}
{{^isContainer}}
{{^isEnum}}
{{{dataType}}} {{classname}}::{{getter}}() const
{
{{#isNullable}}
return m_{{name}}.get();
{{/isNullable}}
{{^isNullable}}
return m_{{name}};
{{/isNullable}}
}
{{/isEnum}}
{{/isContainer}}
{{#isEnum}}
{{^isMap}}{{#isArray}}{{{baseType}}}<{{/isArray}}{{{classname}}}::{{{enumName}}}{{#isArray}}>{{/isArray}}{{/isMap}}{{#isMap}}{{{dataType}}}{{/isMap}} {{classname}}::{{getter}}() const
{
{{#isNullable}}
return m_{{name}}.get();
{{/isNullable}}
{{^isNullable}}
return m_{{name}};
{{/isNullable}}
}
{{/isEnum}}

Expand All @@ -433,17 +490,29 @@ void {{classname}}::{{setter}}(const {{^isMap}}{{{datatypeWithEnum}}}{{/isMap}}{
{{/isEnum}}
{
m_{{name}} = value;
{{^isNullable}}
m_{{name}}IsSet = true;
{{/isNullable}}
}

bool {{classname}}::{{nameInCamelCase}}IsSet() const
{
{{#isNullable}}
return m_{{name}}.has_value();
{{/isNullable}}
{{^isNullable}}
return m_{{name}}IsSet;
{{/isNullable}}
}

void {{classname}}::unset{{name}}()
{
{{#isNullable}}
m_{{name}}.reset();
{{/isNullable}}
{{^isNullable}}
m_{{name}}IsSet = false;
{{/isNullable}}
}
{{/isInherited}}{{/vars}}
{{/isEnum}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_ApiResponse_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Category_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Color_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Color_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <stdexcept>
#include <variant>
#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Order_H_

#include <stdexcept>
#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Page_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Page_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Pet_H_

#include <stdexcept>
#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_SchemaWithSet_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_SchemaWithSet_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_SchemaWithSet_vaccinationBook_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_SchemaWithSet_vaccinationBook_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Tag_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_User_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_
#define ORG_OPENAPITOOLS_CLIENT_MODEL_Vaccine_H_

#include <boost/optional.hpp>

#include "CppRestPetstoreClient/ModelBase.h"

Expand Down Expand Up @@ -71,8 +72,7 @@ class Vaccine


protected:
std::shared_ptr<AnyType> m_date;
bool m_dateIsSet;
boost::optional<std::shared_ptr<AnyType>> m_date;

bool m_BoosterRequired;
bool m_BoosterRequiredIsSet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ web::json::value ApiResponse::toJson() const
{
web::json::value val = web::json::value::object();
if(m_CodeIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("code"))] = ModelBase::toJson(m_Code);
}
if(m_TypeIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("type"))] = ModelBase::toJson(m_Type);
}
if(m_MessageIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("message"))] = ModelBase::toJson(m_Message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ web::json::value Category::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("id"))] = ModelBase::toJson(m_Id);
}
if(m_NameIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("name"))] = ModelBase::toJson(m_Name);
}
Expand Down
12 changes: 6 additions & 6 deletions samples/client/petstore/cpp-restsdk/client/src/model/Order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,34 +46,34 @@ web::json::value Order::toJson() const
{
web::json::value val = web::json::value::object();
if(m_IdIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("id"))] = ModelBase::toJson(m_Id);
}
if(m_PetIdIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("petId"))] = ModelBase::toJson(m_PetId);
}
if(m_QuantityIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("quantity"))] = ModelBase::toJson(m_Quantity);
}
if(m_ShipDateIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("shipDate"))] = ModelBase::toJson(m_ShipDate);
}
if(m_StatusIsSet)
{
{

utility::string_t refVal = fromStatusEnum(m_Status);
val[utility::conversions::to_string_t(_XPLATSTR("status"))] = ModelBase::toJson(refVal);

}
if(m_CompleteIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("complete"))] = ModelBase::toJson(m_Complete);
}
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/cpp-restsdk/client/src/model/Page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,17 @@ web::json::value Page::toJson() const
{
web::json::value val = web::json::value::object();
if(m_PageIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("page"))] = ModelBase::toJson(m_Page);
}
if(m_PerPageIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("perPage"))] = ModelBase::toJson(m_PerPage);
}
if(m_Reference_testIsSet)
{
{

val[utility::conversions::to_string_t(_XPLATSTR("reference_test"))] = ModelBase::toJson(m_Reference_test);
}
Expand Down
Loading
Loading