mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-21 02:17:09 +00:00
Improve templates for C++ Restbed (#10543)
* Improve templates for C++ Restbed The templates now generate classes which have virtual functions that can be overridden to implement handlers. * Fix missing HTTP methods in generated restbed C++ code There was a wrong handling of "x-codegen-other-methods". Change-Id: If6526d2672434beb5ebb0871d84cb80d84c34c38
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator 5.0.0-SNAPSHOT.
|
||||
* NOTE: This class is auto generated by OpenAPI-Generator unset.
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
@@ -15,7 +15,9 @@
|
||||
#include "Order.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <algorithm>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
@@ -29,29 +31,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Order::Order()
|
||||
Order::Order(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Id = 0L;
|
||||
m_PetId = 0L;
|
||||
m_Quantity = 0;
|
||||
m_ShipDate = "";
|
||||
m_Status = "";
|
||||
m_StatusEnum = { "placed", "approved", "delivered" };
|
||||
m_Complete = false;
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
Order::~Order()
|
||||
std::string Order::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string Order::toJsonString(bool prettyJson)
|
||||
void Order::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Order::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Order::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Order::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Order::fromJsonString(std::string const& jsonString)
|
||||
void Order::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -59,7 +71,7 @@ void Order::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Order::toPropertyTree()
|
||||
ptree Order::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -72,7 +84,7 @@ ptree Order::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Order::fromPropertyTree(ptree const &pt)
|
||||
void Order::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
@@ -87,6 +99,7 @@ int64_t Order::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Order::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
@@ -95,6 +108,7 @@ int64_t Order::getPetId() const
|
||||
{
|
||||
return m_PetId;
|
||||
}
|
||||
|
||||
void Order::setPetId(int64_t value)
|
||||
{
|
||||
m_PetId = value;
|
||||
@@ -103,6 +117,7 @@ int32_t Order::getQuantity() const
|
||||
{
|
||||
return m_Quantity;
|
||||
}
|
||||
|
||||
void Order::setQuantity(int32_t value)
|
||||
{
|
||||
m_Quantity = value;
|
||||
@@ -111,6 +126,7 @@ std::string Order::getShipDate() const
|
||||
{
|
||||
return m_ShipDate;
|
||||
}
|
||||
|
||||
void Order::setShipDate(std::string value)
|
||||
{
|
||||
m_ShipDate = value;
|
||||
@@ -119,6 +135,7 @@ std::string Order::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
|
||||
void Order::setStatus(std::string value)
|
||||
{
|
||||
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
|
||||
@@ -131,11 +148,26 @@ bool Order::isComplete() const
|
||||
{
|
||||
return m_Complete;
|
||||
}
|
||||
|
||||
void Order::setComplete(bool value)
|
||||
{
|
||||
m_Complete = value;
|
||||
}
|
||||
|
||||
std::vector<Order> createOrderVectorFromJsonString(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<Order>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Order(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user