mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-05-13 13:10:53 +00:00
* Continuing from #1317 and its PRs for pistache server string enum code generation; * A class that has an `anyOf` specification, in cpp side will have no members: in stead it should have a member having the type `classname_anyOf` * Thus, Its `==` operator is not present or wrongly filled * An string enum, should have a better usage, hence the `setEnumValue` * this PR, is a brigde between `stringenumclassname_anyOf` and `stringenumclassname` * `anyOf` specification is not just about `Enums`, so a better handling is needed from mustache templates, hence new template model parameter `isStringEnumContainer` * PR fix: muttleyxd: `double semicolon` * PR fix: wing328: `I think std::string is C++ only. What about adding x-is-string-enum-container instead in the postProcessModel operation in the C++ pistache server generator?` * PR fix: wing328: `I think std::string is C++ only...` after fix get latest codes and then generate samples Co-authored-by: Mehmet Fatih <mfyuce@netas.com.tr>
252 lines
5.1 KiB
C++
252 lines
5.1 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 "Order.h"
|
|
#include "Helpers.h"
|
|
|
|
#include <sstream>
|
|
|
|
namespace org::openapitools::server::model
|
|
{
|
|
|
|
Order::Order()
|
|
{
|
|
m_Id = 0L;
|
|
m_IdIsSet = false;
|
|
m_PetId = 0L;
|
|
m_PetIdIsSet = false;
|
|
m_Quantity = 0;
|
|
m_QuantityIsSet = false;
|
|
m_ShipDate = "";
|
|
m_ShipDateIsSet = false;
|
|
m_Status = "";
|
|
m_StatusIsSet = false;
|
|
m_Complete = false;
|
|
m_CompleteIsSet = false;
|
|
|
|
}
|
|
|
|
void Order::validate() const
|
|
{
|
|
std::stringstream msg;
|
|
if (!validate(msg))
|
|
{
|
|
throw org::openapitools::server::helpers::ValidationException(msg.str());
|
|
}
|
|
}
|
|
|
|
bool Order::validate(std::stringstream& msg) const
|
|
{
|
|
return validate(msg, "");
|
|
}
|
|
|
|
bool Order::validate(std::stringstream& msg, const std::string& pathPrefix) const
|
|
{
|
|
bool success = true;
|
|
const std::string _pathPrefix = pathPrefix.empty() ? "Order" : pathPrefix;
|
|
|
|
|
|
return success;
|
|
}
|
|
|
|
bool Order::operator==(const Order& rhs) const
|
|
{
|
|
return
|
|
|
|
|
|
|
|
((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) &&
|
|
|
|
|
|
((!petIdIsSet() && !rhs.petIdIsSet()) || (petIdIsSet() && rhs.petIdIsSet() && getPetId() == rhs.getPetId())) &&
|
|
|
|
|
|
((!quantityIsSet() && !rhs.quantityIsSet()) || (quantityIsSet() && rhs.quantityIsSet() && getQuantity() == rhs.getQuantity())) &&
|
|
|
|
|
|
((!shipDateIsSet() && !rhs.shipDateIsSet()) || (shipDateIsSet() && rhs.shipDateIsSet() && getShipDate() == rhs.getShipDate())) &&
|
|
|
|
|
|
((!statusIsSet() && !rhs.statusIsSet()) || (statusIsSet() && rhs.statusIsSet() && getStatus() == rhs.getStatus())) &&
|
|
|
|
|
|
((!completeIsSet() && !rhs.completeIsSet()) || (completeIsSet() && rhs.completeIsSet() && isComplete() == rhs.isComplete()))
|
|
|
|
;
|
|
}
|
|
|
|
bool Order::operator!=(const Order& rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
void to_json(nlohmann::json& j, const Order& o)
|
|
{
|
|
j = nlohmann::json();
|
|
if(o.idIsSet())
|
|
j["id"] = o.m_Id;
|
|
if(o.petIdIsSet())
|
|
j["petId"] = o.m_PetId;
|
|
if(o.quantityIsSet())
|
|
j["quantity"] = o.m_Quantity;
|
|
if(o.shipDateIsSet())
|
|
j["shipDate"] = o.m_ShipDate;
|
|
if(o.statusIsSet())
|
|
j["status"] = o.m_Status;
|
|
if(o.completeIsSet())
|
|
j["complete"] = o.m_Complete;
|
|
|
|
}
|
|
|
|
void from_json(const nlohmann::json& j, Order& o)
|
|
{
|
|
if(j.find("id") != j.end())
|
|
{
|
|
j.at("id").get_to(o.m_Id);
|
|
o.m_IdIsSet = true;
|
|
}
|
|
if(j.find("petId") != j.end())
|
|
{
|
|
j.at("petId").get_to(o.m_PetId);
|
|
o.m_PetIdIsSet = true;
|
|
}
|
|
if(j.find("quantity") != j.end())
|
|
{
|
|
j.at("quantity").get_to(o.m_Quantity);
|
|
o.m_QuantityIsSet = true;
|
|
}
|
|
if(j.find("shipDate") != j.end())
|
|
{
|
|
j.at("shipDate").get_to(o.m_ShipDate);
|
|
o.m_ShipDateIsSet = true;
|
|
}
|
|
if(j.find("status") != j.end())
|
|
{
|
|
j.at("status").get_to(o.m_Status);
|
|
o.m_StatusIsSet = true;
|
|
}
|
|
if(j.find("complete") != j.end())
|
|
{
|
|
j.at("complete").get_to(o.m_Complete);
|
|
o.m_CompleteIsSet = true;
|
|
}
|
|
|
|
}
|
|
|
|
int64_t Order::getId() const
|
|
{
|
|
return m_Id;
|
|
}
|
|
void Order::setId(int64_t const value)
|
|
{
|
|
m_Id = value;
|
|
m_IdIsSet = true;
|
|
}
|
|
bool Order::idIsSet() const
|
|
{
|
|
return m_IdIsSet;
|
|
}
|
|
void Order::unsetId()
|
|
{
|
|
m_IdIsSet = false;
|
|
}
|
|
int64_t Order::getPetId() const
|
|
{
|
|
return m_PetId;
|
|
}
|
|
void Order::setPetId(int64_t const value)
|
|
{
|
|
m_PetId = value;
|
|
m_PetIdIsSet = true;
|
|
}
|
|
bool Order::petIdIsSet() const
|
|
{
|
|
return m_PetIdIsSet;
|
|
}
|
|
void Order::unsetPetId()
|
|
{
|
|
m_PetIdIsSet = false;
|
|
}
|
|
int32_t Order::getQuantity() const
|
|
{
|
|
return m_Quantity;
|
|
}
|
|
void Order::setQuantity(int32_t const value)
|
|
{
|
|
m_Quantity = value;
|
|
m_QuantityIsSet = true;
|
|
}
|
|
bool Order::quantityIsSet() const
|
|
{
|
|
return m_QuantityIsSet;
|
|
}
|
|
void Order::unsetQuantity()
|
|
{
|
|
m_QuantityIsSet = false;
|
|
}
|
|
std::string Order::getShipDate() const
|
|
{
|
|
return m_ShipDate;
|
|
}
|
|
void Order::setShipDate(std::string const& value)
|
|
{
|
|
m_ShipDate = value;
|
|
m_ShipDateIsSet = true;
|
|
}
|
|
bool Order::shipDateIsSet() const
|
|
{
|
|
return m_ShipDateIsSet;
|
|
}
|
|
void Order::unsetShipDate()
|
|
{
|
|
m_ShipDateIsSet = false;
|
|
}
|
|
std::string Order::getStatus() const
|
|
{
|
|
return m_Status;
|
|
}
|
|
void Order::setStatus(std::string const& value)
|
|
{
|
|
m_Status = value;
|
|
m_StatusIsSet = true;
|
|
}
|
|
bool Order::statusIsSet() const
|
|
{
|
|
return m_StatusIsSet;
|
|
}
|
|
void Order::unsetStatus()
|
|
{
|
|
m_StatusIsSet = false;
|
|
}
|
|
bool Order::isComplete() const
|
|
{
|
|
return m_Complete;
|
|
}
|
|
void Order::setComplete(bool const value)
|
|
{
|
|
m_Complete = value;
|
|
m_CompleteIsSet = true;
|
|
}
|
|
bool Order::completeIsSet() const
|
|
{
|
|
return m_CompleteIsSet;
|
|
}
|
|
void Order::unsetComplete()
|
|
{
|
|
m_CompleteIsSet = false;
|
|
}
|
|
|
|
|
|
} // namespace org::openapitools::server::model
|
|
|