Add info about default values to describe
Change-Id: I9919e0d366b56ac17e7b606aa5aa0ae048b447c3
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 046bfcd..6290429 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -460,3 +460,20 @@
{
return getSchemaNode(path.c_str())->flags() & LYS_CONFIG_W;
}
+
+std::optional<std::string> YangSchema::defaultValue(const std::string& leafPath) const
+{
+ libyang::Schema_Node_Leaf leaf(getSchemaNode(leafPath));
+
+ if (auto leafDefault = leaf.dflt()) {
+ return leafDefault;
+ }
+
+ for (auto type = leaf.type()->der(); type != nullptr; type = type->type()->der()) {
+ if (auto defaultValue = type->dflt()) {
+ return defaultValue;
+ }
+ }
+
+ return std::nullopt;
+}