From a5f8b6fe923a6449da81ef1e06cd23fab338c29f Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Fri, 5 Apr 2013 14:38:52 +0200 Subject: [PATCH] Front-end: Changed documentation overview, basePath is now determined and apps with long pathes are shown, however only last segment of path is displayed, might be a Swagger issue --- html/admin/js/views/appDocumentationView.js | 3 ++- js/apps/aardvark/aardvark.js | 23 +++++++++++++-------- js/apps/aardvark/repositories/swagger.js | 16 +++++++++----- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/html/admin/js/views/appDocumentationView.js b/html/admin/js/views/appDocumentationView.js index 89420f7ce5..f2d8d96295 100644 --- a/html/admin/js/views/appDocumentationView.js +++ b/html/admin/js/views/appDocumentationView.js @@ -5,7 +5,8 @@ window.AppDocumentationView = Backbone.View.extend({ initialize: function() { this.swaggerUi = new SwaggerUi({ - discoveryUrl:"../aardvark/swagger", + discoveryUrl:"../aardvark/docus", + apiKey: false, dom_id:"swagger-ui-container", supportHeaderParams: true, diff --git a/js/apps/aardvark/aardvark.js b/js/apps/aardvark/aardvark.js index fd0c15751e..5bfb2ea1a9 100644 --- a/js/apps/aardvark/aardvark.js +++ b/js/apps/aardvark/aardvark.js @@ -76,26 +76,31 @@ required: true, allowMultiple: false }).nickname("foxxes") - .summary("List of all foxxes.") - .notes("This function simply returns the list of all running" - + " foxxes and supplies the paths for the swagger documentation"); + .summary("Update a foxx.") + .notes("Used to either activate/deactivate a foxx, or change the mount point."); app.get('/foxxes', function (req, res) { res.json(repositories.foxxes.viewAll()); }).nickname("foxxes") - .summary("Update a foxx.") - .notes("Used to either activate/deactivate a foxx, or change the mount point."); + .summary("List of all foxxes.") + .notes("This function simply returns the list of all running foxxes"); app.get('/docus', function (req, res) { - res.json(repositories.docus.list()); + res.json(repositories.docus.list("http://" + req.headers.host + req.path + "/")); }).nickname("swaggers") - .summary("List of all foxxes.") + .summary("List documentation of all foxxes.") .notes("This function simply returns the list of all running" + " foxxes and supplies the paths for the swagger documentation"); - app.get('/docus/:appname', function(req, res) { - res.json(repositories.docus.show(req.params("appname"))) + app.get('/docus/*', function(req, res) { + var mountPoint = ""; + require("underscore").each(req.suffix, function(part) { + mountPoint += "/" + part; + }); + + //require("console").log(JSON.stringify(req)); + res.json(repositories.docus.show(mountPoint)) }).pathParam("appname", { description: "The mount point of the App the documentation should be requested for", dataType: "string", diff --git a/js/apps/aardvark/repositories/swagger.js b/js/apps/aardvark/repositories/swagger.js index 8534bbec2d..7b94cf51fa 100644 --- a/js/apps/aardvark/repositories/swagger.js +++ b/js/apps/aardvark/repositories/swagger.js @@ -41,16 +41,23 @@ exports.Repository = Foxx.Repository.extend({ // Get the overview of all installed foxxes. - list: function() { + list: function(basePath) { var result = {}, apis = [], routes = db._collection("_routing"), res = db._collection("_aal").byExample({"type": "mount"}); result.swaggerVersion = "1.1"; - result.basePath = "http://127.0.0.1:8529/aardvark/docus/"; + result.basePath = basePath; result.apis = apis; while (res.hasNext()) { - apis.push({path: res.next().mount}); + var m = res.next().mount; + if (m === "/aardvark") { + + } else { + apis.push({ + path: m + }); + } } return result; }, @@ -59,7 +66,6 @@ show: function(appname) { var result = {}, apis = [], - key, pathes, regex = /(:)([^\/]*)/, i, @@ -67,7 +73,7 @@ api, ops, routes = db._collection("_routing"), - key = db._collection("_aal").firstExample({"mount": "/" + appname})._key, + key = db._collection("_aal").firstExample({"mount": appname})._key, app = routes.firstExample({"foxxMount": key}); result.swaggerVersion = "1.1"; result.basePath = app.urlPrefix;