09-03-2019 12:24 AM
Hi all,
I tried to generate a swagger api documentation based on a ncs service with yanger.
How to interpret the swagger output? Is this the correct output?
I cannot find any information about the ncs service inside the swagger output.
YANG model:
module: testservice augment /ncs:services: +--rw testservice* [infra-type infra-location] +---x check-sync | +---w input | | +---w outformat? outformat4 | | +---w (depth)? | | | +--:(deep) [Omitted output]
Command:
yanger --format=swagger --output=/tmp/testservice.swagger -t expand --swagger-host 127.0.0.1:8080 --swagger-basepath /restconf /var/opt/ncs/packages/testservice/src/yang/testservice.yang
Output:
Common information:
$ ncs --version 4.7.2.1 $ yanger --version yanger 1.0
Thanks.
Solved! Go to Solution.
09-03-2019 08:43 AM
Hello,
you are augmenting the /ncs:services container in your model so you need to get the swagger output of this module to see your service.
this is working using a package test:
yanger --swagger-path-filter=/data/tailf-ncs-services:services/test:test --format=swagger -t expand --output=/tmp/testservice.swagger --swagger-host 127.0.0.1:8080 /var/nso-5.2.0.3/src/ncs/yang/tailf-ncs.yang /path/to/file/test.yang
(Note with the current version of yanger - using yanger 1.0 coming with NSO 5.2.0.3 here this works for me because I don't have any "data" in my augmenting module as swagger currently accept only one data module for swagger plugin)
My package yang model looks like:
module test { namespace "http://example.com/test"; prefix test; import ietf-inet-types { prefix inet; } import tailf-common { prefix tailf; } import tailf-ncs { prefix ncs; } description "Bla bla..."; revision 2016-01-01 { description "Initial revision."; } augment "/ncs:services" { list test { description "This is an RFS skeleton service"; key name; leaf name { tailf:info "Unique service id"; tailf:cli-allow-range; type string; } uses ncs:service-data; ncs:servicepoint test-servicepoint; // may replace this with other ways of refering to the devices. leaf-list device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } // replace with your own stuff here leaf dummy { type inet:ipv4-address; } } } }
09-03-2019 08:43 AM
Hello,
you are augmenting the /ncs:services container in your model so you need to get the swagger output of this module to see your service.
this is working using a package test:
yanger --swagger-path-filter=/data/tailf-ncs-services:services/test:test --format=swagger -t expand --output=/tmp/testservice.swagger --swagger-host 127.0.0.1:8080 /var/nso-5.2.0.3/src/ncs/yang/tailf-ncs.yang /path/to/file/test.yang
(Note with the current version of yanger - using yanger 1.0 coming with NSO 5.2.0.3 here this works for me because I don't have any "data" in my augmenting module as swagger currently accept only one data module for swagger plugin)
My package yang model looks like:
module test { namespace "http://example.com/test"; prefix test; import ietf-inet-types { prefix inet; } import tailf-common { prefix tailf; } import tailf-ncs { prefix ncs; } description "Bla bla..."; revision 2016-01-01 { description "Initial revision."; } augment "/ncs:services" { list test { description "This is an RFS skeleton service"; key name; leaf name { tailf:info "Unique service id"; tailf:cli-allow-range; type string; } uses ncs:service-data; ncs:servicepoint test-servicepoint; // may replace this with other ways of refering to the devices. leaf-list device { type leafref { path "/ncs:devices/ncs:device/ncs:name"; } } // replace with your own stuff here leaf dummy { type inet:ipv4-address; } } } }
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide