1
0
Fork 0

fixed (hacked) display of swagger for dev apps

This commit is contained in:
Frank Celler 2013-08-07 13:30:28 +02:00
parent af057e40d3
commit 487af3bc0d
5 changed files with 75 additions and 15 deletions

View File

@ -172,7 +172,7 @@ HttpHandler::status_e RestDocumentHandler::execute () {
/// @RESTHEADER{POST /_api/document,creates a document}
///
/// @RESTBODYPARAM{document,json,required}
/// A JSON representation of document.
/// A JSON representation of the document.
///
/// @RESTQUERYPARAMETERS
///
@ -839,6 +839,9 @@ bool RestDocumentHandler::checkDocument () {
///
/// @RESTHEADER{PUT /_api/document/`document-handle`,replaces a document}
///
/// @RESTBODYPARAM{document,json,required}
/// A JSON representation of the new document.
///
/// @RESTURLPARAMETERS
///
/// @RESTURLPARAM{document-handle,string,required}
@ -1054,6 +1057,9 @@ bool RestDocumentHandler::replaceDocument () {
///
/// @RESTHEADER{PATCH /_api/document/`document-handle`,patches a document}
///
/// @RESTBODYPARAM{document,json,required}
/// A JSON representation of the new document.
///
/// @RESTURLPARAMETERS
///
/// @RESTURLPARAM{document-handle,string,required}

View File

@ -8,7 +8,7 @@
<meta name="description" content="ArangoDB Admin Web Interface">
<meta name="author" content="Heiko Kernbach">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
<!-- NO EXTERNAL LINKS link href='http://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css' -->
<link href='css/droidsans.css' rel='stylesheet' type='text/css'/>
<link href='css/swagger/hightlight.default.css' media='screen' rel='stylesheet' type='text/css'/>

View File

@ -88,7 +88,7 @@ exports.Foxxes = function () {
// Define the functionality to display all foxxes
this.viewAll = function () {
return aal.toArray();
return aal.toArray().concat(foxxmanager.developmentMounts());
};
// Define the functionality to update one foxx.

View File

@ -66,17 +66,27 @@ exports.Swagger = function () {
this.listOne = function(basePath, key) {
var result = {},
res = _aal.document(key);
res;
if (key.substr(0, 4) === "dev:") {
res = "/dev/" + key.split(":")[2];
}
else {
res = _aal.document(key).mount;
}
result.swaggerVersion = "1.1";
result.basePath = basePath;
result.apis = [
{path: res.mount}
{path: res}
];
return result;
},
// Get details of one specific installed foxx.
this.show = function(appname) {
this.show = function(mount) {
var result = {},
apis = [],
pathes,
@ -85,25 +95,22 @@ exports.Swagger = function () {
url,
api,
ops,
foxxApp = _aal.firstExample({"mount": appname}),
app,
list;
if (!foxxApp.development) {
list = foxx_manager.appRoutes();
} else {
list = foxx_manager.developmentRoutes();
}
list = foxx_manager.appRoutes().concat(foxx_manager.developmentRoutes());
_.each(list, function(r) {
var ac = r.appContext;
if (ac.appId === foxxApp.app && ac.mount === foxxApp.mount) {
if (ac.mount === mount) {
app = r;
return;
}
});
result.swaggerVersion = "1.1";
result.basePath = app.urlPrefix;
result.apis = apis;
pathes = app.routes;
for (i in pathes) {
if (pathes[i].url.methods !== undefined) {
url = pathes[i].url.match;
@ -116,6 +123,7 @@ exports.Swagger = function () {
apis.push(api);
}
}
return result;
}
};

View File

@ -37,6 +37,16 @@ var executeGlobalContextFunction = require("internal").executeGlobalContextFunct
var checkParameter = arangodb.checkParameter;
var transformScript = require("org/arangodb/foxx/transformer").transform;
// -----------------------------------------------------------------------------
// --SECTION-- private variables
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @brief development mounts
////////////////////////////////////////////////////////////////////////////////
var DEVELOPMENTMOUNTS = null;
// -----------------------------------------------------------------------------
// --SECTION-- private functions
// -----------------------------------------------------------------------------
@ -1013,6 +1023,7 @@ exports.appRoutes = function () {
exports.developmentRoutes = function () {
'use strict';
var mounts = [];
var routes = [];
var root = module.devAppPath();
@ -1029,7 +1040,7 @@ exports.developmentRoutes = function () {
var appId = "dev:" + mf.name + ":" + files[j];
var mount = "/dev/" + files[j];
var options = {
prefix : prefixFromMount(mount) || undefined
prefix : prefixFromMount(mount)
};
var app = module.createApp(appId, options);
@ -1050,6 +1061,23 @@ exports.developmentRoutes = function () {
routes.push(r);
console.log("Mounted dev app '%s' on '%s'", appId, mount);
var desc = {
_id: "dev/" + app._id,
_key: app._id,
type: "mount",
app: app._id,
name: app._name,
description: app._manifest.description,
author: app._manifest.author,
mount: mount,
active: true,
collectionPrefix: options.prefix,
isSystem: app._manifest.isSystem || false,
options: options
};
mounts.push(desc);
}
catch (err) {
console.error("Cannot read app manifest '%s': %s", m, String(err.stack || err));
@ -1057,9 +1085,27 @@ exports.developmentRoutes = function () {
}
}
DEVELOPMENTMOUNTS = mounts;
return routes;
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the development mounts
///
/// Must be called after developmentRoutes.
////////////////////////////////////////////////////////////////////////////////
exports.developmentMounts = function () {
'use strict';
if (DEVELOPMENTMOUNTS === null) {
exports.developmentRoutes();
}
return DEVELOPMENTMOUNTS;
};
// -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE
// -----------------------------------------------------------------------------