forked from loafle/openapi-generator-original
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 "ApiResponse.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
@@ -28,25 +30,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
ApiResponse::ApiResponse()
|
||||
ApiResponse::ApiResponse(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Code = 0;
|
||||
m_Type = "";
|
||||
m_Message = "";
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ApiResponse::~ApiResponse()
|
||||
std::string ApiResponse::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string ApiResponse::toJsonString(bool 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(std::string const& jsonString)
|
||||
void ApiResponse::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -54,7 +70,7 @@ void ApiResponse::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree ApiResponse::toPropertyTree()
|
||||
ptree ApiResponse::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -64,7 +80,7 @@ ptree ApiResponse::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void ApiResponse::fromPropertyTree(ptree const &pt)
|
||||
void ApiResponse::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Code = pt.get("code", 0);
|
||||
@@ -76,6 +92,7 @@ int32_t ApiResponse::getCode() const
|
||||
{
|
||||
return m_Code;
|
||||
}
|
||||
|
||||
void ApiResponse::setCode(int32_t value)
|
||||
{
|
||||
m_Code = value;
|
||||
@@ -84,6 +101,7 @@ std::string ApiResponse::getType() const
|
||||
{
|
||||
return m_Type;
|
||||
}
|
||||
|
||||
void ApiResponse::setType(std::string value)
|
||||
{
|
||||
m_Type = value;
|
||||
@@ -92,11 +110,26 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -36,8 +37,9 @@ namespace model {
|
||||
class ApiResponse
|
||||
{
|
||||
public:
|
||||
ApiResponse();
|
||||
virtual ~ApiResponse();
|
||||
ApiResponse() = default;
|
||||
explicit ApiResponse(boost::property_tree::ptree const& pt);
|
||||
virtual ~ApiResponse() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -64,12 +66,26 @@ public:
|
||||
/// </summary>
|
||||
std::string getMessage() const;
|
||||
void setMessage(std::string value);
|
||||
|
||||
protected:
|
||||
int32_t m_Code;
|
||||
std::string m_Type;
|
||||
std::string m_Message;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int32_t m_Code = 0;
|
||||
std::string m_Type = "";
|
||||
std::string m_Message = "";
|
||||
};
|
||||
|
||||
std::vector<ApiResponse> createApiResponseVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "Category.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
@@ -28,24 +30,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Category::Category()
|
||||
Category::Category(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Id = 0L;
|
||||
m_Name = "";
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
Category::~Category()
|
||||
std::string Category::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string Category::toJsonString(bool prettyJson)
|
||||
void Category::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Category::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Category::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Category::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Category::fromJsonString(std::string const& jsonString)
|
||||
void Category::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -53,7 +70,7 @@ void Category::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Category::toPropertyTree()
|
||||
ptree Category::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -62,7 +79,7 @@ ptree Category::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Category::fromPropertyTree(ptree const &pt)
|
||||
void Category::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
@@ -73,6 +90,7 @@ int64_t Category::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Category::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
@@ -81,11 +99,26 @@ std::string Category::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Category::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(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<Category>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Category(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -36,8 +37,9 @@ namespace model {
|
||||
class Category
|
||||
{
|
||||
public:
|
||||
Category();
|
||||
virtual ~Category();
|
||||
Category() = default;
|
||||
explicit Category(boost::property_tree::ptree const& pt);
|
||||
virtual ~Category() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -58,11 +60,25 @@ public:
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
std::string m_Name;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Name = "";
|
||||
};
|
||||
|
||||
std::vector<Category> createCategoryVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -24,6 +24,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -37,8 +39,9 @@ namespace model {
|
||||
class Order
|
||||
{
|
||||
public:
|
||||
Order();
|
||||
virtual ~Order();
|
||||
Order() = default;
|
||||
explicit Order(boost::property_tree::ptree const& pt);
|
||||
virtual ~Order() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -83,16 +86,33 @@ public:
|
||||
/// </summary>
|
||||
bool isComplete() const;
|
||||
void setComplete(bool value);
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
int64_t m_PetId;
|
||||
int32_t m_Quantity;
|
||||
std::string m_ShipDate;
|
||||
std::string m_Status;
|
||||
bool m_Complete;
|
||||
std::vector<std::string> m_StatusEnum;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
int64_t m_PetId = 0L;
|
||||
int32_t m_Quantity = 0;
|
||||
std::string m_ShipDate = "";
|
||||
std::string m_Status = "";
|
||||
bool m_Complete = false;
|
||||
const std::array<std::string, 3> m_StatusEnum = {
|
||||
"placed","approved","delivered"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
std::vector<Order> createOrderVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "Pet.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,26 +31,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Pet::Pet()
|
||||
Pet::Pet(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Id = 0L;
|
||||
m_Name = "";
|
||||
m_Status = "";
|
||||
m_StatusEnum = { "available", "pending", "sold" };
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
Pet::~Pet()
|
||||
std::string Pet::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string Pet::toJsonString(bool prettyJson)
|
||||
void Pet::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Pet::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Pet::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Pet::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Pet::fromJsonString(std::string const& jsonString)
|
||||
void Pet::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -56,7 +71,7 @@ void Pet::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Pet::toPropertyTree()
|
||||
ptree Pet::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -68,9 +83,9 @@ ptree Pet::toPropertyTree()
|
||||
// generate tree for PhotoUrls
|
||||
if (!m_PhotoUrls.empty()) {
|
||||
for (const auto &childEntry : m_PhotoUrls) {
|
||||
ptree PhotoUrls_node;
|
||||
PhotoUrls_node.put("", childEntry);
|
||||
tmp_node.push_back(std::make_pair("", PhotoUrls_node));
|
||||
ptree PhotoUrls_node;
|
||||
PhotoUrls_node.put("", childEntry);
|
||||
tmp_node.push_back(std::make_pair("", PhotoUrls_node));
|
||||
}
|
||||
pt.add_child("photoUrls", tmp_node);
|
||||
tmp_node.clear();
|
||||
@@ -78,9 +93,7 @@ ptree Pet::toPropertyTree()
|
||||
// generate tree for Tags
|
||||
if (!m_Tags.empty()) {
|
||||
for (const auto &childEntry : m_Tags) {
|
||||
ptree Tags_node;
|
||||
Tags_node.put("", childEntry);
|
||||
tmp_node.push_back(std::make_pair("", Tags_node));
|
||||
tmp_node.push_back(std::make_pair("", childEntry->toPropertyTree()));
|
||||
}
|
||||
pt.add_child("tags", tmp_node);
|
||||
tmp_node.clear();
|
||||
@@ -89,7 +102,7 @@ ptree Pet::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Pet::fromPropertyTree(ptree const &pt)
|
||||
void Pet::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
@@ -101,13 +114,17 @@ void Pet::fromPropertyTree(ptree const &pt)
|
||||
// push all items of PhotoUrls into member vector
|
||||
if (pt.get_child_optional("photoUrls")) {
|
||||
for (const auto &childTree : pt.get_child("photoUrls")) {
|
||||
m_PhotoUrls.emplace_back(childTree.second.data());
|
||||
std::string val =
|
||||
childTree.second.data();
|
||||
m_PhotoUrls.emplace_back(std::move(val));
|
||||
}
|
||||
}
|
||||
// push all items of Tags into member vector
|
||||
if (pt.get_child_optional("tags")) {
|
||||
for (const auto &childTree : pt.get_child("tags")) {
|
||||
m_Tags.emplace_back(childTree.second.data());
|
||||
std::shared_ptr<Tag> val =
|
||||
std::make_shared<Tag>(childTree.second);
|
||||
m_Tags.emplace_back(std::move(val));
|
||||
}
|
||||
}
|
||||
setStatus(pt.get("status", ""));
|
||||
@@ -117,6 +134,7 @@ int64_t Pet::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Pet::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
@@ -125,6 +143,7 @@ std::shared_ptr<Category> Pet::getCategory() const
|
||||
{
|
||||
return m_Category;
|
||||
}
|
||||
|
||||
void Pet::setCategory(std::shared_ptr<Category> value)
|
||||
{
|
||||
m_Category = value;
|
||||
@@ -133,6 +152,7 @@ std::string Pet::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Pet::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
@@ -141,6 +161,7 @@ std::vector<std::string> Pet::getPhotoUrls() const
|
||||
{
|
||||
return m_PhotoUrls;
|
||||
}
|
||||
|
||||
void Pet::setPhotoUrls(std::vector<std::string> value)
|
||||
{
|
||||
m_PhotoUrls = value;
|
||||
@@ -149,6 +170,7 @@ std::vector<std::shared_ptr<Tag>> Pet::getTags() const
|
||||
{
|
||||
return m_Tags;
|
||||
}
|
||||
|
||||
void Pet::setTags(std::vector<std::shared_ptr<Tag>> value)
|
||||
{
|
||||
m_Tags = value;
|
||||
@@ -157,6 +179,7 @@ std::string Pet::getStatus() const
|
||||
{
|
||||
return m_Status;
|
||||
}
|
||||
|
||||
void Pet::setStatus(std::string value)
|
||||
{
|
||||
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
|
||||
@@ -166,6 +189,20 @@ void Pet::setStatus(std::string value)
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<Pet> createPetVectorFromJsonString(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<Pet>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Pet(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "Category.h"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -39,8 +41,9 @@ namespace model {
|
||||
class Pet
|
||||
{
|
||||
public:
|
||||
Pet();
|
||||
virtual ~Pet();
|
||||
Pet() = default;
|
||||
explicit Pet(boost::property_tree::ptree const& pt);
|
||||
virtual ~Pet() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -85,16 +88,33 @@ public:
|
||||
/// </summary>
|
||||
std::string getStatus() const;
|
||||
void setStatus(std::string value);
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::shared_ptr<Category> m_Category;
|
||||
std::string m_Name;
|
||||
std::string m_Name = "";
|
||||
std::vector<std::string> m_PhotoUrls;
|
||||
std::vector<std::shared_ptr<Tag>> m_Tags;
|
||||
std::string m_Status;
|
||||
std::vector<std::string> m_StatusEnum;
|
||||
std::string m_Status = "";
|
||||
const std::array<std::string, 3> m_StatusEnum = {
|
||||
"available","pending","sold"
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
std::vector<Pet> createPetVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "Tag.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
@@ -28,24 +30,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
Tag::Tag()
|
||||
Tag::Tag(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Id = 0L;
|
||||
m_Name = "";
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
Tag::~Tag()
|
||||
std::string Tag::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string Tag::toJsonString(bool prettyJson)
|
||||
void Tag::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree Tag::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void Tag::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string Tag::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void Tag::fromJsonString(std::string const& jsonString)
|
||||
void Tag::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -53,7 +70,7 @@ void Tag::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree Tag::toPropertyTree()
|
||||
ptree Tag::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -62,7 +79,7 @@ ptree Tag::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void Tag::fromPropertyTree(ptree const &pt)
|
||||
void Tag::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
@@ -73,6 +90,7 @@ int64_t Tag::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void Tag::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
@@ -81,11 +99,26 @@ std::string Tag::getName() const
|
||||
{
|
||||
return m_Name;
|
||||
}
|
||||
|
||||
void Tag::setName(std::string value)
|
||||
{
|
||||
m_Name = value;
|
||||
}
|
||||
|
||||
std::vector<Tag> createTagVectorFromJsonString(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<Tag>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(Tag(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -36,8 +37,9 @@ namespace model {
|
||||
class Tag
|
||||
{
|
||||
public:
|
||||
Tag();
|
||||
virtual ~Tag();
|
||||
Tag() = default;
|
||||
explicit Tag(boost::property_tree::ptree const& pt);
|
||||
virtual ~Tag() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -58,11 +60,25 @@ public:
|
||||
/// </summary>
|
||||
std::string getName() const;
|
||||
void setName(std::string value);
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
std::string m_Name;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Name = "";
|
||||
};
|
||||
|
||||
std::vector<Tag> createTagVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 "User.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
#include <boost/property_tree/json_parser.hpp>
|
||||
|
||||
@@ -28,30 +30,39 @@ namespace openapitools {
|
||||
namespace server {
|
||||
namespace model {
|
||||
|
||||
User::User()
|
||||
User::User(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
m_Id = 0L;
|
||||
m_Username = "";
|
||||
m_FirstName = "";
|
||||
m_LastName = "";
|
||||
m_Email = "";
|
||||
m_Password = "";
|
||||
m_Phone = "";
|
||||
m_UserStatus = 0;
|
||||
fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
User::~User()
|
||||
std::string User::toJsonString(bool prettyJson /* = false */)
|
||||
{
|
||||
return toJsonString_internal(prettyJson);
|
||||
}
|
||||
|
||||
std::string User::toJsonString(bool prettyJson)
|
||||
void User::fromJsonString(std::string const& jsonString)
|
||||
{
|
||||
fromJsonString_internal(jsonString);
|
||||
}
|
||||
|
||||
boost::property_tree::ptree User::toPropertyTree()
|
||||
{
|
||||
return toPropertyTree_internal();
|
||||
}
|
||||
|
||||
void User::fromPropertyTree(boost::property_tree::ptree const& pt)
|
||||
{
|
||||
fromPropertyTree_internal(pt);
|
||||
}
|
||||
|
||||
std::string User::toJsonString_internal(bool prettyJson)
|
||||
{
|
||||
std::stringstream ss;
|
||||
write_json(ss, this->toPropertyTree(), prettyJson);
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
void User::fromJsonString(std::string const& jsonString)
|
||||
void User::fromJsonString_internal(std::string const& jsonString)
|
||||
{
|
||||
std::stringstream ss(jsonString);
|
||||
ptree pt;
|
||||
@@ -59,7 +70,7 @@ void User::fromJsonString(std::string const& jsonString)
|
||||
this->fromPropertyTree(pt);
|
||||
}
|
||||
|
||||
ptree User::toPropertyTree()
|
||||
ptree User::toPropertyTree_internal()
|
||||
{
|
||||
ptree pt;
|
||||
ptree tmp_node;
|
||||
@@ -74,7 +85,7 @@ ptree User::toPropertyTree()
|
||||
return pt;
|
||||
}
|
||||
|
||||
void User::fromPropertyTree(ptree const &pt)
|
||||
void User::fromPropertyTree_internal(ptree const &pt)
|
||||
{
|
||||
ptree tmp_node;
|
||||
m_Id = pt.get("id", 0L);
|
||||
@@ -91,6 +102,7 @@ int64_t User::getId() const
|
||||
{
|
||||
return m_Id;
|
||||
}
|
||||
|
||||
void User::setId(int64_t value)
|
||||
{
|
||||
m_Id = value;
|
||||
@@ -99,6 +111,7 @@ std::string User::getUsername() const
|
||||
{
|
||||
return m_Username;
|
||||
}
|
||||
|
||||
void User::setUsername(std::string value)
|
||||
{
|
||||
m_Username = value;
|
||||
@@ -107,6 +120,7 @@ std::string User::getFirstName() const
|
||||
{
|
||||
return m_FirstName;
|
||||
}
|
||||
|
||||
void User::setFirstName(std::string value)
|
||||
{
|
||||
m_FirstName = value;
|
||||
@@ -115,6 +129,7 @@ std::string User::getLastName() const
|
||||
{
|
||||
return m_LastName;
|
||||
}
|
||||
|
||||
void User::setLastName(std::string value)
|
||||
{
|
||||
m_LastName = value;
|
||||
@@ -123,6 +138,7 @@ std::string User::getEmail() const
|
||||
{
|
||||
return m_Email;
|
||||
}
|
||||
|
||||
void User::setEmail(std::string value)
|
||||
{
|
||||
m_Email = value;
|
||||
@@ -131,6 +147,7 @@ std::string User::getPassword() const
|
||||
{
|
||||
return m_Password;
|
||||
}
|
||||
|
||||
void User::setPassword(std::string value)
|
||||
{
|
||||
m_Password = value;
|
||||
@@ -139,6 +156,7 @@ std::string User::getPhone() const
|
||||
{
|
||||
return m_Phone;
|
||||
}
|
||||
|
||||
void User::setPhone(std::string value)
|
||||
{
|
||||
m_Phone = value;
|
||||
@@ -147,11 +165,26 @@ int32_t User::getUserStatus() const
|
||||
{
|
||||
return m_UserStatus;
|
||||
}
|
||||
|
||||
void User::setUserStatus(int32_t value)
|
||||
{
|
||||
m_UserStatus = value;
|
||||
}
|
||||
|
||||
std::vector<User> createUserVectorFromJsonString(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<User>();
|
||||
for (const auto& child: pt) {
|
||||
vec.emplace_back(User(child.second));
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
namespace org {
|
||||
@@ -36,8 +37,9 @@ namespace model {
|
||||
class User
|
||||
{
|
||||
public:
|
||||
User();
|
||||
virtual ~User();
|
||||
User() = default;
|
||||
explicit User(boost::property_tree::ptree const& pt);
|
||||
virtual ~User() = default;
|
||||
|
||||
std::string toJsonString(bool prettyJson = false);
|
||||
void fromJsonString(std::string const& jsonString);
|
||||
@@ -94,17 +96,31 @@ public:
|
||||
/// </summary>
|
||||
int32_t getUserStatus() const;
|
||||
void setUserStatus(int32_t value);
|
||||
|
||||
protected:
|
||||
int64_t m_Id;
|
||||
std::string m_Username;
|
||||
std::string m_FirstName;
|
||||
std::string m_LastName;
|
||||
std::string m_Email;
|
||||
std::string m_Password;
|
||||
std::string m_Phone;
|
||||
int32_t m_UserStatus;
|
||||
//////////////////////////////////////
|
||||
// Override these for customization //
|
||||
//////////////////////////////////////
|
||||
|
||||
virtual std::string toJsonString_internal(bool prettyJson = false);
|
||||
virtual void fromJsonString_internal(std::string const& jsonString);
|
||||
virtual boost::property_tree::ptree toPropertyTree_internal();
|
||||
virtual void fromPropertyTree_internal(boost::property_tree::ptree const& pt);
|
||||
|
||||
|
||||
protected:
|
||||
int64_t m_Id = 0L;
|
||||
std::string m_Username = "";
|
||||
std::string m_FirstName = "";
|
||||
std::string m_LastName = "";
|
||||
std::string m_Email = "";
|
||||
std::string m_Password = "";
|
||||
std::string m_Phone = "";
|
||||
int32_t m_UserStatus = 0;
|
||||
};
|
||||
|
||||
std::vector<User> createUserVectorFromJsonString(const std::string& json);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user