forked from loafle/openapi-generator-original
* Keep old implementation of cpp-restbed generator as cpp-restbed-server-deprecated * Refactor operation path processing * Restructure samples directory to better allow writing tests * Improve templates for cpp-restbed-server Improve templates * Add integration tests * Improvement in templates for cpp-restbed-server * Fix tests * Improve cpp-restbed generator * Improve cpp-restbed-server * Add more tests * Add suppoert for arrays of enums in query params * Generate CMakeLists.txt * Small improvements and example in Readme * Add integration tests to maven project * Update doc
138 lines
2.7 KiB
C++
138 lines
2.7 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 unset.
|
|
* https://openapi-generator.tech
|
|
* Do not edit the class manually.
|
|
*/
|
|
|
|
|
|
|
|
#include "ApiResponse.h"
|
|
|
|
#include <string>
|
|
#include <vector>
|
|
#include <sstream>
|
|
#include <stdexcept>
|
|
#include <boost/property_tree/ptree.hpp>
|
|
#include <boost/property_tree/json_parser.hpp>
|
|
|
|
using boost::property_tree::ptree;
|
|
using boost::property_tree::read_json;
|
|
using boost::property_tree::write_json;
|
|
|
|
namespace org {
|
|
namespace openapitools {
|
|
namespace server {
|
|
namespace model {
|
|
|
|
ApiResponse::ApiResponse(boost::property_tree::ptree const& pt)
|
|
{
|
|
fromPropertyTree(pt);
|
|
}
|
|
|
|
std::string ApiResponse::toJsonString(bool prettyJson /* = false */)
|
|
{
|
|
return toJsonString_internal(prettyJson);
|
|
}
|
|
|
|
void ApiResponse::fromJsonString(std::string const& jsonString)
|
|
{
|
|
fromJsonString_internal(jsonString);
|
|
}
|
|
|
|
boost::property_tree::ptree ApiResponse::toPropertyTree()
|
|
{
|
|
return toPropertyTree_internal();
|
|
}
|
|
|
|
void ApiResponse::fromPropertyTree(boost::property_tree::ptree const& pt)
|
|
{
|
|
fromPropertyTree_internal(pt);
|
|
}
|
|
|
|
std::string ApiResponse::toJsonString_internal(bool prettyJson)
|
|
{
|
|
std::stringstream ss;
|
|
write_json(ss, this->toPropertyTree(), prettyJson);
|
|
return ss.str();
|
|
}
|
|
|
|
void ApiResponse::fromJsonString_internal(std::string const& jsonString)
|
|
{
|
|
std::stringstream ss(jsonString);
|
|
ptree pt;
|
|
read_json(ss,pt);
|
|
this->fromPropertyTree(pt);
|
|
}
|
|
|
|
ptree ApiResponse::toPropertyTree_internal()
|
|
{
|
|
ptree pt;
|
|
ptree tmp_node;
|
|
pt.put("code", m_Code);
|
|
pt.put("type", m_Type);
|
|
pt.put("message", m_Message);
|
|
return pt;
|
|
}
|
|
|
|
void ApiResponse::fromPropertyTree_internal(ptree const &pt)
|
|
{
|
|
ptree tmp_node;
|
|
m_Code = pt.get("code", 0);
|
|
m_Type = pt.get("type", "");
|
|
m_Message = pt.get("message", "");
|
|
}
|
|
|
|
int32_t ApiResponse::getCode() const
|
|
{
|
|
return m_Code;
|
|
}
|
|
|
|
void ApiResponse::setCode(int32_t value)
|
|
{
|
|
m_Code = value;
|
|
}
|
|
std::string ApiResponse::getType() const
|
|
{
|
|
return m_Type;
|
|
}
|
|
|
|
void ApiResponse::setType(std::string value)
|
|
{
|
|
m_Type = value;
|
|
}
|
|
std::string ApiResponse::getMessage() const
|
|
{
|
|
return m_Message;
|
|
}
|
|
|
|
void ApiResponse::setMessage(std::string value)
|
|
{
|
|
m_Message = value;
|
|
}
|
|
|
|
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json)
|
|
{
|
|
std::stringstream sstream(json);
|
|
boost::property_tree::ptree pt;
|
|
boost::property_tree::json_parser::read_json(sstream,pt);
|
|
|
|
auto vec = std::vector<ApiResponse>();
|
|
for (const auto& child: pt) {
|
|
vec.emplace_back(ApiResponse(child.second));
|
|
}
|
|
|
|
return vec;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|