From: Peter Suna Date: Wed, 20 Apr 2022 13:10:07 +0000 (+0200) Subject: Fix docgen for action types X-Git-Tag: v4.0.0~82 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F72%2F100672%2F3;hp=0226b5a21bb755b75a25b208fd0ecca20fd8968c;p=netconf.git Fix docgen for action types When we are processing actions we need to adjust the stack to enter each of them for the duration of traversal. Also add the corresponding test. JIRA: NETCONF-872 Change-Id: I5aae78380073c4d5c876b888b22cd41a2657db2d Signed-off-by: Peter Suna Signed-off-by: Robert Varga --- diff --git a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java index f7817c0daf..bd2ef8e83a 100644 --- a/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java +++ b/restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/DefinitionGenerator.java @@ -257,7 +257,9 @@ public class DefinitionGenerator { final SchemaInferenceStack stack, final OAversion oaversion) throws IOException { for (final ActionDefinition actionDef : ((ActionNodeContainer) childNode).getActions()) { + stack.enterSchemaTree(actionDef.getQName()); processOperations(actionDef, moduleName, definitions, definitionNames, stack, oaversion); + stack.exit(); } } diff --git a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java index 889606d7e6..f37b8ee692 100644 --- a/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java +++ b/restconf/sal-rest-docgen/src/test/java/org/opendaylight/controller/sal/rest/doc/impl/SwaggerObjectTest.java @@ -40,6 +40,16 @@ public final class SwaggerObjectTest { Assert.assertNotNull(jsonObject); } + @Test + public void testActionTypes() throws Exception { + final Optional module = context.findModule("action-types"); + assertTrue("Desired module not found", module.isPresent()); + final DefinitionGenerator generator = new DefinitionGenerator(); + final ObjectNode jsonObject = generator.convertToJsonSchema(module.get(), context, + new DefinitionNames(), ApiDocServiceImpl.OAversion.V2_0, true); + Assert.assertNotNull(jsonObject); + } + @Test public void testStringTypes() throws Exception { final Optional module = context.findModule("string-types"); diff --git a/restconf/sal-rest-docgen/src/test/resources/yang/action-types.yang b/restconf/sal-rest-docgen/src/test/resources/yang/action-types.yang new file mode 100644 index 0000000000..4d6d316e3e --- /dev/null +++ b/restconf/sal-rest-docgen/src/test/resources/yang/action-types.yang @@ -0,0 +1,50 @@ +module action-types { + yang-version 1.1; + namespace "urn:ietf:params:xml:ns:yang:test:action:types"; + prefix "act-tp"; + + list list { + key name; + leaf name { + type string; + } + action list-action { + input { + leaf la-input { + type string; + mandatory true; + } + } + output { + leaf la-output { + type string; + mandatory true; + } + } + } + } + + container container { + action container-action { + input { + leaf ca-input { + type string; + mandatory true; + } + } + output { + leaf ca-output { + type string; + mandatory true; + } + } + } + } + + container multi-container { + container inner-container { + action action { + } + } + } +}