Bug 5998 - fix operations request example body 80/45580/3
authormiroslav.kovac <miroslav.kovac@pantheon.tech>
Tue, 13 Sep 2016 15:38:05 +0000 (17:38 +0200)
committerMiroslav Kovac <miroslav.kovac@pantheon.tech>
Wed, 21 Sep 2016 13:09:16 +0000 (13:09 +0000)
Change-Id: I4e5d56a58527b48d32836f25e74b12a1a0aad703
Signed-off-by: miroslav.kovac <miroslav.kovac@pantheon.tech>
restconf/sal-rest-docgen/src/main/java/org/opendaylight/netconf/sal/rest/doc/impl/ModelGenerator.java

index 1a94b21141cdf65bf013a6f99ccec6fc8a8c1c82..40a41f3be3be96aa7b8e2bfa0c78e69a1ce787a2 100644 (file)
@@ -151,26 +151,31 @@ public class ModelGenerator {
      */
     private void processRPCs(final Module module, final JSONObject models, final SchemaContext schemaContext) throws JSONException,
             IOException {
-
         final Set<RpcDefinition> rpcs = module.getRpcs();
         final String moduleName = module.getName();
         for (final RpcDefinition rpc : rpcs) {
-
             final ContainerSchemaNode input = rpc.getInput();
             if (input != null) {
-                final JSONObject inputJSON = processDataNodeContainer(input, moduleName, models, schemaContext);
+                final JSONObject properties = processChildren(input.getChildNodes(), input.getQName(), moduleName,
+                        models, true, schemaContext);
                 final String filename = "(" + rpc.getQName().getLocalName() + ")input";
-                inputJSON.put("id", filename);
-                // writeToFile(filename, inputJSON.toString(2), moduleName);
-                models.put(filename, inputJSON);
+                final JSONObject childSchema = getSchemaTemplate();
+                childSchema.put(TYPE_KEY, OBJECT_TYPE);
+                childSchema.put(PROPERTIES_KEY, properties);
+                childSchema.put("id", filename);
+                models.put(filename, childSchema);
             }
 
             final ContainerSchemaNode output = rpc.getOutput();
             if (output != null) {
-                final JSONObject outputJSON = processDataNodeContainer(output, moduleName, models, schemaContext);
+                final JSONObject properties = processChildren(output.getChildNodes(), output.getQName(), moduleName,
+                        models, true, schemaContext);
                 final String filename = "(" + rpc.getQName().getLocalName() + ")output";
-                outputJSON.put("id", filename);
-                models.put(filename, outputJSON);
+                final JSONObject childSchema = getSchemaTemplate();
+                childSchema.put(TYPE_KEY, OBJECT_TYPE);
+                childSchema.put(PROPERTIES_KEY, properties);
+                childSchema.put("id", filename);
+                models.put(filename, childSchema);
             }
         }
     }
@@ -227,14 +232,6 @@ public class ModelGenerator {
         }
     }
 
-    /**
-     * Processes the container and list nodes and populates the moduleJSON.
-     */
-    private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models,
-            final SchemaContext schemaContext) throws JSONException, IOException {
-        return processDataNodeContainer(dataNode, moduleName, models, true, schemaContext);
-    }
-
     private JSONObject processDataNodeContainer(final DataNodeContainer dataNode, final String moduleName, final JSONObject models,
             final boolean isConfig, final SchemaContext schemaContext) throws JSONException, IOException {
         if (dataNode instanceof ListSchemaNode || dataNode instanceof ContainerSchemaNode) {