diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java index 5d0a703453..10070ece51 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/NodeJSServerCodegen.java @@ -207,11 +207,14 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig } @SuppressWarnings("unchecked") - private Map getOperations(Map objs) { + private List> getOperations(Map objs) { + List> result = new ArrayList>(); Map apiInfo = (Map) objs.get("apiInfo"); List> apis = (List>) apiInfo.get("apis"); - Map api = apis.get(0); - return (Map) api.get("operations"); + for (Map api : apis) { + result.add((Map) api.get("operations")); + } + return result; } private List> sortOperationsByPath(List ops) { @@ -221,7 +224,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig opsByPath.put(op.path, op); } - List> opsByPathList = new ArrayList>(); + List> opsByPathList = new ArrayList>(); for (Entry> entry : opsByPath.asMap().entrySet()) { Map opsByPathEntry = new HashMap(); opsByPathList.add(opsByPathEntry); @@ -239,16 +242,13 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig @Override public Map postProcessSupportingFileData(Map objs) { - Map operations = getOperations(objs); - - if (operations != null) { + for (Map operations : getOperations(objs)) { @SuppressWarnings("unchecked") List ops = (List) operations.get("operation"); List> opsByPathList = sortOperationsByPath(ops); operations.put("operationsByPath", opsByPathList); } - return super.postProcessSupportingFileData(objs); } } \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache index 59940f08b1..3b975e53b8 100644 --- a/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache +++ b/modules/swagger-codegen/src/main/resources/nodejs/swagger.mustache @@ -14,7 +14,7 @@ {{#operations}} {{#operationsByPath}} "{{{path}}}": { - {{#operation}} + {{#operation}} "{{httpMethod}}": { "summary": "{{summary}}", "description":"{{notes}}", @@ -34,7 +34,6 @@ {{/operation}} } {{#hasMore}},{{/hasMore}} {{/operationsByPath}} - {{#hasMore}},{{/hasMore}} {{/operations}} {{/apis}} {{/apiInfo}}