forked from loafle/openapi-generator-original
261 lines
5.6 KiB
C++
261 lines
5.6 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.
|
|
*
|
|
* The version of the OpenAPI document: 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"
|
|
#include "Helpers.h"
|
|
|
|
#include <sstream>
|
|
|
|
namespace org::openapitools::server::model
|
|
{
|
|
|
|
Pet::Pet()
|
|
{
|
|
m_Id = 0L;
|
|
m_IdIsSet = false;
|
|
m_CategoryIsSet = false;
|
|
m_Name = "";
|
|
m_TagsIsSet = false;
|
|
m_Status = "";
|
|
m_StatusIsSet = false;
|
|
|
|
}
|
|
|
|
void Pet::validate() const
|
|
{
|
|
std::stringstream msg;
|
|
if (!validate(msg))
|
|
{
|
|
throw org::openapitools::server::helpers::ValidationException(msg.str());
|
|
}
|
|
}
|
|
|
|
bool Pet::validate(std::stringstream& msg) const
|
|
{
|
|
return validate(msg, "");
|
|
}
|
|
|
|
bool Pet::validate(std::stringstream& msg, const std::string& pathPrefix) const
|
|
{
|
|
bool success = true;
|
|
const std::string _pathPrefix = pathPrefix.empty() ? "Pet" : pathPrefix;
|
|
|
|
|
|
|
|
/* PhotoUrls */ {
|
|
const std::vector<std::string>& value = m_PhotoUrls;
|
|
const std::string currentValuePath = _pathPrefix + ".photoUrls";
|
|
|
|
|
|
{ // Recursive validation of array elements
|
|
const std::string oldValuePath = currentValuePath;
|
|
int i = 0;
|
|
for (const std::string& value : value)
|
|
{
|
|
const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]";
|
|
|
|
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
if (tagsIsSet())
|
|
{
|
|
const std::vector<org::openapitools::server::model::Tag>& value = m_Tags;
|
|
const std::string currentValuePath = _pathPrefix + ".tags";
|
|
|
|
|
|
{ // Recursive validation of array elements
|
|
const std::string oldValuePath = currentValuePath;
|
|
int i = 0;
|
|
for (const org::openapitools::server::model::Tag& value : value)
|
|
{
|
|
const std::string currentValuePath = oldValuePath + "[" + std::to_string(i) + "]";
|
|
|
|
success = value.validate(msg, currentValuePath + ".tags") && success;
|
|
|
|
i++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
bool Pet::operator==(const Pet& rhs) const
|
|
{
|
|
return
|
|
|
|
|
|
|
|
((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) &&
|
|
|
|
|
|
((!categoryIsSet() && !rhs.categoryIsSet()) || (categoryIsSet() && rhs.categoryIsSet() && getCategory() == rhs.getCategory())) &&
|
|
|
|
(getName() == rhs.getName())
|
|
&&
|
|
|
|
(getPhotoUrls() == rhs.getPhotoUrls())
|
|
&&
|
|
|
|
|
|
((!tagsIsSet() && !rhs.tagsIsSet()) || (tagsIsSet() && rhs.tagsIsSet() && getTags() == rhs.getTags())) &&
|
|
|
|
|
|
((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus()))
|
|
|
|
;
|
|
}
|
|
|
|
bool Pet::operator!=(const Pet& rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
void to_json(nlohmann::json& j, const Pet& o)
|
|
{
|
|
j = nlohmann::json();
|
|
if(o.idIsSet())
|
|
j["id"] = o.m_Id;
|
|
if(o.categoryIsSet())
|
|
j["category"] = o.m_Category;
|
|
j["name"] = o.m_Name;
|
|
j["photoUrls"] = o.m_PhotoUrls;
|
|
if(o.tagsIsSet() || !o.m_Tags.empty())
|
|
j["tags"] = o.m_Tags;
|
|
if(o.statusIsSet())
|
|
j["status"] = o.m_Status;
|
|
|
|
}
|
|
|
|
void from_json(const nlohmann::json& j, Pet& o)
|
|
{
|
|
if(j.find("id") != j.end())
|
|
{
|
|
j.at("id").get_to(o.m_Id);
|
|
o.m_IdIsSet = true;
|
|
}
|
|
if(j.find("category") != j.end())
|
|
{
|
|
j.at("category").get_to(o.m_Category);
|
|
o.m_CategoryIsSet = true;
|
|
}
|
|
j.at("name").get_to(o.m_Name);
|
|
j.at("photoUrls").get_to(o.m_PhotoUrls);
|
|
if(j.find("tags") != j.end())
|
|
{
|
|
j.at("tags").get_to(o.m_Tags);
|
|
o.m_TagsIsSet = true;
|
|
}
|
|
if(j.find("status") != j.end())
|
|
{
|
|
j.at("status").get_to(o.m_Status);
|
|
o.m_StatusIsSet = true;
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
|
}
|
|
org::openapitools::server::model::Category Pet::getCategory() const
|
|
{
|
|
return m_Category;
|
|
}
|
|
void Pet::setCategory(org::openapitools::server::model::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() const
|
|
{
|
|
return m_PhotoUrls;
|
|
}
|
|
void Pet::setPhotoUrls(std::vector<std::string> const& value)
|
|
{
|
|
m_PhotoUrls = value;
|
|
}
|
|
std::vector<org::openapitools::server::model::Tag> Pet::getTags() const
|
|
{
|
|
return m_Tags;
|
|
}
|
|
void Pet::setTags(std::vector<org::openapitools::server::model::Tag> const& value)
|
|
{
|
|
m_Tags = value;
|
|
m_TagsIsSet = true;
|
|
}
|
|
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;
|
|
}
|
|
|
|
|
|
} // namespace org::openapitools::server::model
|
|
|