Fixing NPE caused when rpc definition does not include "input" or "output"
[netconf.git] / restconf / sal-rest-docgen / src / main / java / org / opendaylight / netconf / sal / rest / doc / impl / ModelGenerator.java
index 75bfe75d0cd3d5ca00c586851690dd91f031633b..ede1f20c43c2a6ff7bfc9c1129248370359db881 100644 (file)
@@ -150,7 +150,8 @@ public class ModelGenerator {
         final String moduleName = module.getName();
         for (final RpcDefinition rpc : rpcs) {
             final ContainerSchemaNode input = rpc.getInput();
-            if (!input.getChildNodes().isEmpty()) {
+            if (input !=null && input.getChildNodes() != null &&
+                    !input.getChildNodes().isEmpty()) {
                 final JSONObject properties = processChildren(input.getChildNodes(), moduleName, models, true, schemaContext);
 
                 final String filename = "(" + rpc.getQName().getLocalName() + ")input";
@@ -164,7 +165,8 @@ public class ModelGenerator {
             }
 
             final ContainerSchemaNode output = rpc.getOutput();
-            if (!output.getChildNodes().isEmpty()) {
+            if (output !=null && output.getChildNodes() != null &&
+                    !output.getChildNodes().isEmpty()) {
                 final JSONObject properties = processChildren(output.getChildNodes(), moduleName, models, true, schemaContext);
                 final String filename = "(" + rpc.getQName().getLocalName() + ")output";
                 final JSONObject childSchema = getSchemaTemplate();
@@ -606,4 +608,4 @@ public class ModelGenerator {
         return schemaJSON;
     }
 
-}
\ No newline at end of file
+}