Fix leafTypeName returning names of primitive types

This means describe won't tell me
"example-schema:leaf: string (a string)", but just
"example-schema:leaf: (a string)".

Change-Id: I736bf655f3301a61b76485b15cf123448459047e
diff --git a/src/yang_schema.cpp b/src/yang_schema.cpp
index 6021cc5..132c25f 100644
--- a/src/yang_schema.cpp
+++ b/src/yang_schema.cpp
@@ -304,7 +304,7 @@
 std::optional<std::string> YangSchema::leafTypeName(const std::string& path) const
 {
     libyang::Schema_Node_Leaf leaf(getSchemaNode(path));
-    return leaf.type()->der().get() ? std::optional{leaf.type()->der()->name()} : std::nullopt;
+    return leaf.type()->der().get() && leaf.type()->der()->type()->der().get() ? std::optional{leaf.type()->der()->name()} : std::nullopt;
 }
 
 std::string YangSchema::leafrefPath(const std::string& leafrefPath) const
diff --git a/src/yang_schema.hpp b/src/yang_schema.hpp
index 2a93b07..a4c0b90 100644
--- a/src/yang_schema.hpp
+++ b/src/yang_schema.hpp
@@ -41,6 +41,7 @@
     const std::set<std::string> listKeys(const schemaPath_& location, const ModuleNodePair& node) const override;
     yang::TypeInfo leafType(const schemaPath_& location, const ModuleNodePair& node) const override;
     yang::TypeInfo leafType(const std::string& path) const override;
+    /** @brief If the leaf type is a typedef, returns the typedef name. */
     std::optional<std::string> leafTypeName(const std::string& path) const override;
     std::string leafrefPath(const std::string& leafrefPath) const override;
     std::set<ModuleNodePair> availableNodes(const boost::variant<dataPath_, schemaPath_, module_>& path, const Recursion recursion) const override;