Libyang goes on to parse the yang and replace the content from another yang i.e it resolves the union whereas pyang output remains the same as the 1st yang was created.
Due to issue 1 it is unable to find the module name of the 3rd yang i.e libyang-test-2 because it's imported in yang no. 2(libyang-test-1.yang) and not in 1(libyang-test.yang). So after resolution of union, libyang corrupts the path of leafref.
YANG 1: libyang-test.yang
module libyang-test{
yang-version 1.1;
namespace "urn:libyang:params:xml:ns:yang:libyang-test";
prefix test;
import libyang-test-1 {
prefix test1;
}
container y {
leaf z {
type test1:x;
}
}
}
YANG 2: libyang-test-1.yang
module libyang-test-1{
yang-version 1.1;
namespace "urn:libyang:params:xml:ns:yang:libyang-test-1";
prefix test1;
import libyang-test-2 {
prefix test2;
}
typedef x {
type union {
type leafref {
path "/test2:a/test2:b";
}
type string;
}
}
}
YANG 3: libyang-test-2.yang
module libyang-test-2{
yang-version 1.1;
namespace "urn:libyang:params:xml:ns:yang:libyang-test-2";
prefix test2;
list a
{
key b;
leaf b {
type string;
}
}
}
INVALID OUTPUT :
-bash-4.2$ ./yanglint
> add /localdisk/libyang-test/libyang-test.yang
> print -f yang libyang-test
module libyang-test {
yang-version 1.1;
namespace "urn:libyang:params:xml:ns:yang:libyang-test";
prefix test;
import libyang-test-1 {
prefix test1;
}
container y {
leaf z {
type union {
type leafref {
libyang[0]: Module name "libyang-test-2" refers to an unknown module.
}
type string;
}
}
}
}
>
PYANG OUTPUT :
-bash-4.2$ pyang -f yang libyang-test.yang
module libyang-test {
yang-version 1.1;
namespace "urn:libyang:params:xml:ns:yang:libyang-test";
prefix test;
import libyang-test-1 {
prefix test1;
}
container y {
leaf z {
type test1:x;
}
}
}
ISSUE:
Due to issue 1 it is unable to find the module name of the 3rd yang i.e libyang-test-2 because it's imported in yang no. 2(libyang-test-1.yang) and not in 1(libyang-test.yang). So after resolution of union, libyang corrupts the path of leafref.
YANG 1: libyang-test.yang
YANG 2: libyang-test-1.yang
YANG 3: libyang-test-2.yang
INVALID OUTPUT :
PYANG OUTPUT :