forked from loafle/openapi-generator-original
* [BUG] [C++][Pistache] cpp-pistache-server generating API include undefined "Object.h" (#2769) Should handle Object.h, AnyType.h correctly. Set.h also tested. - #include Object.h removed and replaced by a typeMapping.put(object, nlohmann::json) like suggested in other issues - object had an invalid syntax: ':' instead of '::' in types with namespace - extra include of #include nlohmann/json.h removed when there's already #include <nlohmann/json.hpp> - nlohmann::json is excluded from model namespace Tested with custom petstore played, with suggested openapi specs coming from issues #2769, #10266, #14234 ```bash rm -rf samples/server/petstore/cpp-pistache-everything/ && ./bin/generate-samples.sh ./bin/configs/cpp-pistache-server-cpp-pistache-everything.yaml && cd samples/server/petstore/cpp-pistache-everything/ && mkdir build && cd build && cmake .. && cmake --build . --parallel ``` * - Adding to samples/server/petstore cpp-pistache-everything * - .md and FILES missing
117 lines
2.6 KiB
C++
117 lines
2.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_bestFriends.h"
|
|
#include "Helpers.h"
|
|
|
|
#include <sstream>
|
|
|
|
namespace org::openapitools::server::model
|
|
{
|
|
|
|
Pet_bestFriends::Pet_bestFriends()
|
|
{
|
|
|
|
}
|
|
|
|
void Pet_bestFriends::validate() const
|
|
{
|
|
std::stringstream msg;
|
|
if (!validate(msg))
|
|
{
|
|
throw org::openapitools::server::helpers::ValidationException(msg.str());
|
|
}
|
|
}
|
|
|
|
bool Pet_bestFriends::validate(std::stringstream& msg) const
|
|
{
|
|
return validate(msg, "");
|
|
}
|
|
|
|
bool Pet_bestFriends::validate(std::stringstream& msg, const std::string& pathPrefix) const
|
|
{
|
|
bool success = true;
|
|
const std::string _pathPrefix = pathPrefix.empty() ? "Pet_bestFriends" : pathPrefix;
|
|
|
|
|
|
|
|
/* BestFriends */ {
|
|
const std::vector<std::string>& value = m_BestFriends;
|
|
const std::string currentValuePath = _pathPrefix + ".bestFriends";
|
|
|
|
|
|
if (!org::openapitools::server::helpers::hasOnlyUniqueItems(value))
|
|
{
|
|
success = false;
|
|
msg << currentValuePath << ": may not contain the same item more than once;";
|
|
}
|
|
{ // 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++;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return success;
|
|
}
|
|
|
|
bool Pet_bestFriends::operator==(const Pet_bestFriends& rhs) const
|
|
{
|
|
return
|
|
|
|
|
|
(getBestFriends() == rhs.getBestFriends())
|
|
|
|
|
|
;
|
|
}
|
|
|
|
bool Pet_bestFriends::operator!=(const Pet_bestFriends& rhs) const
|
|
{
|
|
return !(*this == rhs);
|
|
}
|
|
|
|
void to_json(nlohmann::json& j, const Pet_bestFriends& o)
|
|
{
|
|
j = nlohmann::json::object();
|
|
j["bestFriends"] = o.m_BestFriends;
|
|
|
|
}
|
|
|
|
void from_json(const nlohmann::json& j, Pet_bestFriends& o)
|
|
{
|
|
j.at("bestFriends").get_to(o.m_BestFriends);
|
|
|
|
}
|
|
|
|
std::vector<std::string> Pet_bestFriends::getBestFriends() const
|
|
{
|
|
return m_BestFriends;
|
|
}
|
|
void Pet_bestFriends::setBestFriends(std::vector<std::string> const& value)
|
|
{
|
|
m_BestFriends = value;
|
|
}
|
|
|
|
|
|
} // namespace org::openapitools::server::model
|
|
|