From 5902425f529a7d181211177c38df8513c974926b Mon Sep 17 00:00:00 2001 From: Shelby Sanders Date: Sat, 7 Feb 2015 22:58:30 -0800 Subject: [PATCH] Changed Swagger() to omit resources with no content --- lib/swagger.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/swagger.js b/lib/swagger.js index 4c80d64..16ffec1 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -45,7 +45,17 @@ function Swagger(loopbackApplication, swaggerApp, opts) { // A class is an endpoint root; e.g. /users, /products, and so on. classes.forEach(function (aClass) { var doc = apiDocs[aClass.name] = classHelper.generateAPIDoc(aClass, opts); - resourceDoc.apis.push(classHelper.generateResourceDocAPIEntry(aClass)); + var hasPublic = false; + var methods = aClass.methods() + for (var methodKey in methods) { + hasPublic = methods[methodKey].public; + if (hasPublic) { + break; + } + } + if (hasPublic) { + resourceDoc.apis.push(classHelper.generateResourceDocAPIEntry(aClass)); + } // Add the getter for this doc. var docPath = urlJoin(opts.resourcePath, aClass.http.path);