[C++] [Pistache] Model validation, general overhaul (#9251)

* overhaul pistache templates

* fix function signature in model-source
return type now aligns with definition in model-header

* use default keyword for destructors

* generate pistache samples

* move bin/configs/other/cpp-pistache-server-cpp-pistache.yaml to bin/configs/cpp-pistache-server-cpp-pistache.yaml

* Only generate validation body if necessary

* generate pistache samples
This commit is contained in:
Julian G
2021-05-05 10:52:47 +02:00
committed by GitHub
parent 4d2b022619
commit 8f5639554e
40 changed files with 1461 additions and 537 deletions

View File

@@ -12,11 +12,12 @@
#include "User.h"
#include "Helpers.h"
namespace org {
namespace openapitools {
namespace server {
namespace model {
#include <sstream>
namespace org::openapitools::server::model
{
User::User()
{
@@ -39,13 +40,72 @@ User::User()
}
User::~User()
void User::validate() const
{
std::stringstream msg;
if (!validate(msg))
{
throw org::openapitools::server::helpers::ValidationException(msg.str());
}
}
void User::validate()
bool User::validate(std::stringstream& msg) const
{
// TODO: implement validation
return validate(msg, "");
}
bool User::validate(std::stringstream& msg, const std::string& pathPrefix) const
{
bool success = true;
const std::string _pathPrefix = pathPrefix.empty() ? "User" : pathPrefix;
return success;
}
bool User::operator==(const User& rhs) const
{
return
((!idIsSet() && !rhs.idIsSet()) || (idIsSet() && rhs.idIsSet() && getId() == rhs.getId())) &&
((!usernameIsSet() && !rhs.usernameIsSet()) || (usernameIsSet() && rhs.usernameIsSet() && getUsername() == rhs.getUsername())) &&
((!firstNameIsSet() && !rhs.firstNameIsSet()) || (firstNameIsSet() && rhs.firstNameIsSet() && getFirstName() == rhs.getFirstName())) &&
((!lastNameIsSet() && !rhs.lastNameIsSet()) || (lastNameIsSet() && rhs.lastNameIsSet() && getLastName() == rhs.getLastName())) &&
((!emailIsSet() && !rhs.emailIsSet()) || (emailIsSet() && rhs.emailIsSet() && getEmail() == rhs.getEmail())) &&
((!passwordIsSet() && !rhs.passwordIsSet()) || (passwordIsSet() && rhs.passwordIsSet() && getPassword() == rhs.getPassword())) &&
((!phoneIsSet() && !rhs.phoneIsSet()) || (phoneIsSet() && rhs.phoneIsSet() && getPhone() == rhs.getPhone())) &&
((!userStatusIsSet() && !rhs.userStatusIsSet()) || (userStatusIsSet() && rhs.userStatusIsSet() && getUserStatus() == rhs.getUserStatus()))
;
}
bool User::operator!=(const User& rhs) const
{
return !(*this == rhs);
}
void to_json(nlohmann::json& j, const User& o)
@@ -253,8 +313,5 @@ void User::unsetUserStatus()
}
}
}
}
}
} // namespace org::openapitools::server::model