Better allOf handling in fromProperty (#15035)

* fix allOf handling in fromProperty

* add null check, update samples

* update dart generator to handle allof with a single ref
This commit is contained in:
William Cheng
2023-03-26 15:06:27 +08:00
committed by GitHub
parent 56e5122a6a
commit a4dd90c01d
27 changed files with 129 additions and 37 deletions

View File

@@ -20,6 +20,7 @@
#include <sstream>
#include <stdexcept>
#include <regex>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
@@ -63,7 +64,6 @@ ptree AllOfWithSingleRef::toPropertyTree() const
ptree pt;
ptree tmp_node;
pt.put("username", m_Username);
pt.add_child("SingleRefType", m_SingleRefType.toPropertyTree());
return pt;
}
@@ -71,9 +71,6 @@ void AllOfWithSingleRef::fromPropertyTree(ptree const &pt)
{
ptree tmp_node;
m_Username = pt.get("username", "");
if (pt.get_child_optional("SingleRefType")) {
m_SingleRefType = fromPt<SingleRefType>(pt.get_child("SingleRefType"));
}
}
std::string AllOfWithSingleRef::getUsername() const

View File

@@ -25,6 +25,7 @@
#include "SingleRefType.h"
#include <memory>
#include <vector>
#include <array>
#include <boost/property_tree/ptree.hpp>
#include "helpers.h"
@@ -72,7 +73,7 @@ public:
protected:
std::string m_Username = "";
SingleRefType m_SingleRefType;
SingleRefType m_SingleRefType = SingleRefType{};
};
std::vector<AllOfWithSingleRef> createAllOfWithSingleRefVectorFromJsonString(const std::string& json);