Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get remote-augments from modules with data in yanger-swagger plugin #12

Open
gmuloc opened this issue Apr 17, 2020 · 1 comment

Comments

@gmuloc
Copy link

gmuloc commented Apr 17, 2020

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;
    }
  }
}
@gmuloc gmuloc changed the title Cannot get remote-augments in yanger-swagger plugin Cannot get remote-augments from modules with data in yanger-swagger plugin Apr 17, 2020
@mbj4668
Copy link
Owner

mbj4668 commented Aug 21, 2020

Unfortunately I don't know anything about swagger, and the author of the swagger plugin is not active in this project anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants