[cpp-restbed] Added "out-of-the-box" functionality (#4759)

* Added cpp-restbed "out-of-the-box" functionality
* handling class dependencies
* added method override to clean interfaces of ambiguity
* added default values for shared pointers
* fixed _name and name parameters generating the same getters and setters
* updated enum handling
* updated Petstore samples
* updated templates for automated object generation

* fix whitespace

* removed model initialisation

* added model brace initialisation
This commit is contained in:
AlexG
2020-01-02 13:36:22 +01:00
committed by William Cheng
parent 5cc5fbe76a
commit 1cb99e3497
24 changed files with 582 additions and 189 deletions

View File

@@ -5,7 +5,7 @@
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI-Generator 4.2.0-SNAPSHOT.
* NOTE: This class is auto generated by OpenAPI-Generator unset.
* https://openapi-generator.tech
* Do not edit the class manually.
*/
@@ -16,6 +16,7 @@
#include <string>
#include <sstream>
#include <algorithm>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
@@ -30,30 +31,23 @@ namespace model {
Order::Order()
{
m_Id = 0L;
m_PetId = 0L;
m_Quantity = 0;
m_ShipDate = "";
m_Status = "";
m_Complete = false;
m_Id = 0L;
m_PetId = 0L;
m_Quantity = 0;
m_ShipDate = "";
m_Status = "";
m_StatusEnum = { "placed", "approved", "delivered" };
m_Complete = false;
}
Order::~Order()
{
}
std::string Order::toJsonString()
std::string Order::toJsonString(bool prettyJson)
{
std::stringstream ss;
ptree pt;
pt.put("id", m_Id);
pt.put("petId", m_PetId);
pt.put("quantity", m_Quantity);
pt.put("shipDate", m_ShipDate);
pt.put("status", m_Status);
pt.put("complete", m_Complete);
write_json(ss, pt, false);
write_json(ss, this->toPropertyTree(), prettyJson);
return ss.str();
}
@@ -62,11 +56,30 @@ void Order::fromJsonString(std::string const& jsonString)
std::stringstream ss(jsonString);
ptree pt;
read_json(ss,pt);
this->fromPropertyTree(pt);
}
ptree Order::toPropertyTree()
{
ptree pt;
ptree tmp_node;
pt.put("id", m_Id);
pt.put("petId", m_PetId);
pt.put("quantity", m_Quantity);
pt.put("shipDate", m_ShipDate);
pt.put("status", m_Status);
pt.put("complete", m_Complete);
return pt;
}
void Order::fromPropertyTree(ptree const &pt)
{
ptree tmp_node;
m_Id = pt.get("id", 0L);
m_PetId = pt.get("petId", 0L);
m_Quantity = pt.get("quantity", 0);
m_ShipDate = pt.get("shipDate", "");
m_Status = pt.get("status", "");
setStatus(pt.get("status", ""));
m_Complete = pt.get("complete", false);
}
@@ -76,7 +89,7 @@ int64_t Order::getId() const
}
void Order::setId(int64_t value)
{
m_Id = value;
m_Id = value;
}
int64_t Order::getPetId() const
{
@@ -84,7 +97,7 @@ int64_t Order::getPetId() const
}
void Order::setPetId(int64_t value)
{
m_PetId = value;
m_PetId = value;
}
int32_t Order::getQuantity() const
{
@@ -92,7 +105,7 @@ int32_t Order::getQuantity() const
}
void Order::setQuantity(int32_t value)
{
m_Quantity = value;
m_Quantity = value;
}
std::string Order::getShipDate() const
{
@@ -100,7 +113,7 @@ std::string Order::getShipDate() const
}
void Order::setShipDate(std::string value)
{
m_ShipDate = value;
m_ShipDate = value;
}
std::string Order::getStatus() const
{
@@ -108,7 +121,9 @@ std::string Order::getStatus() const
}
void Order::setStatus(std::string value)
{
m_Status = value;
if (std::find(m_StatusEnum.begin(), m_StatusEnum.end(), value) != m_StatusEnum.end()) {
m_Status = value;
}
}
bool Order::isComplete() const
{
@@ -116,7 +131,7 @@ bool Order::isComplete() const
}
void Order::setComplete(bool value)
{
m_Complete = value;
m_Complete = value;
}
}