Mehmet YUCE ccd031a3da
Continuing from #1317 and its PRs for pistache server string enum code generation (#9786)
* 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>
2021-06-20 22:13:38 +08:00

165 lines
3.3 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 "ApiResponse.h"
#include "Helpers.h"
#include <sstream>
namespace org::openapitools::server::model
{
ApiResponse::ApiResponse()
{
m_Code = 0;
m_CodeIsSet = false;
m_Type = "";
m_TypeIsSet = false;
m_Message = "";
m_MessageIsSet = false;
}
void ApiResponse::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
bool ApiResponse::validate(std::stringstream& msg) const
{
return validate(msg, "");
}
bool ApiResponse::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "ApiResponse" : pathPrefix;
return success;
}
bool ApiResponse::operator==(const ApiResponse& rhs) const
{
return
((!codeIsSet() && !rhs.codeIsSet()) || (codeIsSet() && rhs.codeIsSet() && getCode() == rhs.getCode())) &&
((!typeIsSet() && !rhs.typeIsSet()) || (typeIsSet() && rhs.typeIsSet() && getType() == rhs.getType())) &&
((!messageIsSet() && !rhs.messageIsSet()) || (messageIsSet() && rhs.messageIsSet() && getMessage() == rhs.getMessage()))
;
}
bool ApiResponse::operator!=(const ApiResponse& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const ApiResponse& o)
{
j = nlohmann::json();
if(o.codeIsSet())
j["code"] = o.m_Code;
if(o.typeIsSet())
j["type"] = o.m_Type;
if(o.messageIsSet())
j["message"] = o.m_Message;
}
void from_json(const nlohmann::json& j, ApiResponse& o)
{
if(j.find("code") != j.end())
{
j.at("code").get_to(o.m_Code);
o.m_CodeIsSet = true;
}
if(j.find("type") != j.end())
{
j.at("type").get_to(o.m_Type);
o.m_TypeIsSet = true;
}
if(j.find("message") != j.end())
{
j.at("message").get_to(o.m_Message);
o.m_MessageIsSet = true;
}
}
int32_t ApiResponse::getCode() const
{
return m_Code;
}
void ApiResponse::setCode(int32_t const value)
{
m_Code = value;
m_CodeIsSet = true;
}
bool ApiResponse::codeIsSet() const
{
return m_CodeIsSet;
}
void ApiResponse::unsetCode()
{
m_CodeIsSet = false;
}
std::string ApiResponse::getType() const
{
return m_Type;
}
void ApiResponse::setType(std::string const& value)
{
m_Type = value;
m_TypeIsSet = true;
}
bool ApiResponse::typeIsSet() const
{
return m_TypeIsSet;
}
void ApiResponse::unsetType()
{
m_TypeIsSet = false;
}
std::string ApiResponse::getMessage() const
{
return m_Message;
}
void ApiResponse::setMessage(std::string const& value)
{
m_Message = value;
m_MessageIsSet = true;
}
bool ApiResponse::messageIsSet() const
{
return m_MessageIsSet;
}
void ApiResponse::unsetMessage()
{
m_MessageIsSet = false;
}
} // namespace org::openapitools::server::model