yanger
yanger copied to clipboard
Cannot get remote-augments from modules with data in yanger-swagger plugin
When working with yanger-swagger plugin, there is a current limitation (for good reason) to having one YANG data model as input.
The issue it gives is that it then prevent the use of remote-augment from other modules that have "data" in them. Indeed if the remote-module does not have data then it is possible to just pass it as a second yang module in the input:
yanger -f swagger -t expand --swagger-path-filter=/data/parent:parent parent.yang no-data-child.yang -o test
However if child.yang defines also some other data node this will fail the first check in the plugin: https://github.com/mbj4668/yanger/blob/master/plugins/yanger_swagger.erl#L283 (the parsing is done correctly but then it fails in emit)
user@server # yanger -f swagger -t expand [--swagger-path-filter=/data/parent:parent](url) parent.yang child.yang -o test
child.yang:0: error: Too many modules given, only one data module is supported for Swagger.
Workaround: if child.yang with data is added as a deviation-module
then it works (I mean I can get the remote-augment to work) - I think this is because it bypass the check from the swagger-plugin emit function.
yanger -f swagger -t expand --swagger-path-filter=/data/parent:parent --deviation-module=child.yang parent.yang -o test
While I understand the current restriction - it is a bit non-intuitive to use deviation-module option to obtain the expected result.
My 3 dummy yang modules below:
module parent {
namespace "http://example.com/parent";
prefix parent;
import ietf-inet-types {
prefix inet;
}
description
"Bla bla...";
revision 2016-01-01 {
description
"Initial revision.";
}
list parent {
key name;
leaf name {
type string;
}
leaf dummy {
type inet:ipv4-address;
}
}
}
module child {
namespace "http://example.com/child";
prefix child;
import ietf-inet-types {
prefix inet;
}
import parent {
prefix parent;
}
description
"Bla bla...";
revision 2016-01-01 {
description
"Initial revision.";
}
augment "/parent:parent" {
leaf augmenting {
type string;
}
}
list child {
key name;
leaf name {
type string;
}
leaf dummy {
type inet:ipv4-address;
}
}
}
module no-data-child {
namespace "http://example.com/no-data-child";
prefix no-data-child;
import ietf-inet-types {
prefix inet;
}
import parent {
prefix parent;
}
description
"Bla bla...";
revision 2016-01-01 {
description
"Initial revision.";
}
augment "/parent:parent" {
leaf augmenting {
type string;
}
}
}
Unfortunately I don't know anything about swagger, and the author of the swagger plugin is not active in this project anymore.