sunn f8f3a08282
[cpp-pistache]Add support for map (#1359)
* Add support for map
* Add support for nested maps
* Simplify Array and Map Helper
* Use const reference wherever possible
2018-11-03 14:09:31 +01:00

221 lines
3.8 KiB
C++

/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* OpenAPI spec version: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
#include "Pet.h"
namespace org {
namespace openapitools {
namespace server {
namespace model {
Pet::Pet()
{
m_Id = 0L;
m_IdIsSet = false;
m_CategoryIsSet = false;
m_Name = "";
m_TagsIsSet = false;
m_Status = "";
m_StatusIsSet = false;
}
Pet::~Pet()
{
}
void Pet::validate()
{
// TODO: implement validation
}
nlohmann::json Pet::toJson() const
{
nlohmann::json val = nlohmann::json::object();
if(m_IdIsSet)
{
val["id"] = m_Id;
}
if(m_CategoryIsSet)
{
val["category"] = ModelBase::toJson(m_Category);
}
val["name"] = ModelBase::toJson(m_Name);
{
nlohmann::json jsonArray;
for( auto& item : m_PhotoUrls )
{
jsonArray.push_back(ModelBase::toJson(item));
}
val["photoUrls"] = jsonArray;
}
{
nlohmann::json jsonArray;
for( auto& item : m_Tags )
{
jsonArray.push_back(ModelBase::toJson(item));
}
if(jsonArray.size() > 0)
{
val["tags"] = jsonArray;
}
}
if(m_StatusIsSet)
{
val["status"] = ModelBase::toJson(m_Status);
}
return val;
}
void Pet::fromJson(const nlohmann::json& val)
{
if(val.find("id") != val.end())
{
setId(val.at("id"));
}
if(val.find("category") != val.end())
{
if(!val["category"].is_null())
{
Category newItem;
newItem.fromJson(val["category"]);
setCategory( newItem );
}
}
setName(val.at("name"));
{
m_PhotoUrls.clear();
for( auto& item : val["photoUrls"] )
{
m_PhotoUrls.push_back(item);
}
}
{
m_Tags.clear();
if(val.find("tags") != val.end())
{
for( auto& item : val["tags"] )
{
if(item.is_null())
{
m_Tags.push_back( Tag() );
}
else
{
Tag newItem;
newItem.fromJson(item);
m_Tags.push_back( newItem );
}
}
}
}
if(val.find("status") != val.end())
{
setStatus(val.at("status"));
}
}
int64_t Pet::getId() const
{
return m_Id;
}
void Pet::setId(int64_t const value)
{
m_Id = value;
m_IdIsSet = true;
}
bool Pet::idIsSet() const
{
return m_IdIsSet;
}
void Pet::unsetId()
{
m_IdIsSet = false;
}
Category Pet::getCategory() const
{
return m_Category;
}
void Pet::setCategory(Category const& value)
{
m_Category = value;
m_CategoryIsSet = true;
}
bool Pet::categoryIsSet() const
{
return m_CategoryIsSet;
}
void Pet::unsetCategory()
{
m_CategoryIsSet = false;
}
std::string Pet::getName() const
{
return m_Name;
}
void Pet::setName(std::string const& value)
{
m_Name = value;
}
std::vector<std::string>& Pet::getPhotoUrls()
{
return m_PhotoUrls;
}
std::vector<Tag>& Pet::getTags()
{
return m_Tags;
}
bool Pet::tagsIsSet() const
{
return m_TagsIsSet;
}
void Pet::unsetTags()
{
m_TagsIsSet = false;
}
std::string Pet::getStatus() const
{
return m_Status;
}
void Pet::setStatus(std::string const& value)
{
m_Status = value;
m_StatusIsSet = true;
}
bool Pet::statusIsSet() const
{
return m_StatusIsSet;
}
void Pet::unsetStatus()
{
m_StatusIsSet = false;
}
}
}
}
}