1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Jan Steemann 2014-11-06 10:21:44 +01:00
commit 0e661a2b21
6 changed files with 65 additions and 52 deletions

View File

@ -40,9 +40,6 @@ var FoxxController = require("org/arangodb/foxx").Controller,
foxxInstallKey = joi.string().required().description(
"The _key attribute, where the information of this Foxx-Install is stored."
),
foxxMountPoint = joi.string().required().description(
"The mount point, where this Foxx is installed."
),
appname = joi.string().required();
var foxxes = new (require("lib/foxxes").Foxxes)();
@ -289,17 +286,13 @@ controller.get('/docus', function (req, res) {
*
*/
controller.get("/docu/:mount", function (req, res) {
require("console").log("Paul");
controller.get("/docu/:key",function (req, res) {
var subPath = req.path.substr(0, req.path.lastIndexOf("[") - 1),
mount = req.params("mount"),
path = req.protocol + "://" + req.headers.host + "/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(mount) + "/";
require("console").log(docus.listOne(path, mount));
res.json(docus.listOne(path, mount));
}).pathParam("mount", {
type: foxxMountPoint,
allowMultiple: false
}).summary("List documentation of all foxxes.")
key = req.params("key"),
path = req.protocol + "://" + req.headers.host +
"/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(key) + "/";
res.json(docus.listOne(path, key));
}).summary("List documentation of one foxxes.")
.notes("This function simply returns one specific"
+ " foxx and supplies the paths for the swagger documentation");
@ -308,18 +301,12 @@ controller.get("/docu/:mount", function (req, res) {
* Get the Elements of the API Documentation subroutes
*
*/
controller.get('/docu/:mount/:mountPoint', function(req, res) {
require("console").log("Blub");
require("console").log(req.params("mount"));
var mountPoint = decodeURIComponent(req.params("mountPoint"));
require("console").log(mountPoint);
controller.get('/docu/:key/*', function(req, res) {
var mountPoint = "";
underscore.each(req.suffix, function(part) {
mountPoint += "/" + part;
});
res.json(docus.show(mountPoint));
}).pathParam("mount", {
type: foxxMountPoint,
allowMultiple: false
}).pathParam("mountPoint", {
type: foxxMountPoint,
allowMultiple: false
}).summary("List the API for one foxx")
.notes("This function lists the API of the foxx"
+ " running under the given mount point");
@ -437,6 +424,7 @@ controller.get("/query/result/download/:query", function(req, res) {
var internal = require("internal");
query = internal.base64Decode(query);
internal.print(query);
try {
parsedQuery = JSON.parse(query);
}

View File

@ -19,7 +19,7 @@
"api": "api",
"databases": "databases",
"applications": "applications",
"application/documentation/:mount": "appDocumentation",
"application/documentation/:key": "appDocumentation",
"graph": "graphManagement",
"userManagement": "userManagement",
"userProfile": "userProfile",
@ -242,8 +242,8 @@
this.naviView.selectMenuItem('applications-menu');
},
appDocumentation: function (mount) {
var docuView = new window.AppDocumentationView({mount: mount});
appDocumentation: function (key) {
var docuView = new window.AppDocumentationView({key: key});
docuView.render();
this.naviView.selectMenuItem('applications-menu');
},

View File

@ -13,7 +13,7 @@
initialize: function() {
var internal = require("internal");
var url = internal.arango.databasePrefix("/_admin/aardvark/docu/" + encodeURIComponent(this.options.mount));
var url = internal.arango.databasePrefix("/_admin/aardvark/docu/" + this.options.key);
this.swaggerUi = new SwaggerUi({
discoveryUrl: url,
apiKey: false,

View File

@ -106,7 +106,7 @@
list.push(modView.createReadOnlyEntry(
"id_documentationJsonUrl",
"API docs",
"<a href=\"" + link + "\">Link to JSON</a>"
"<a href=\"" + link + "\" target=\"_blank\">JSON-file for Swagger</a>"
));
if (editable) {
list.push(modView.createTextEntry(
@ -208,7 +208,7 @@
showDocu: function(event) {
event.stopPropagation();
window.App.navigate(
"application/documentation/" + encodeURIComponent(this.model.get("mount").substr(1)),
"application/documentation/" + encodeURIComponent(this.model.get("_key")),
{
trigger: true
}

View File

@ -47,35 +47,42 @@ exports.Swagger = function () {
result.swaggerVersion = "1.1";
result.basePath = basePath;
result.apis = apis;
var m;
while (res.hasNext()) {
m = res.next().mount;
if (m !== "/aardvark") {
var m = res.next().mount;
if (m === "/aardvark") {
} else {
apis.push({
path: m
});
}
}
return result;
};
},
this.listOne = function(basePath, mount) {
var result = {};
this.listOne = function(basePath, key) {
var result = {},
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: decodeURIComponent(mount)}
{path: res}
];
require("console").log(result);
return result;
};
},
// Get details of one specific installed foxx.
this.show = function(mount) {
require("console").log(mount);
var result = {},
apis = [],
pathes,
@ -102,20 +109,18 @@ exports.Swagger = function () {
pathes = app.routes;
for (i in pathes) {
if(pathes.hasOwnProperty(i)){
if (pathes[i].url.methods !== undefined) {
url = pathes[i].url.match;
api = {};
ops = [];
url = url.replace(regex, "{$2}");
api.path = url;
ops.push(pathes[i].docs);
api.operations = ops;
apis.push(api);
}
if (pathes[i].url.methods !== undefined) {
url = pathes[i].url.match;
api = {};
ops = [];
url = url.replace(regex, "{$2}");
api.path = url;
ops.push(pathes[i].docs);
api.operations = ops;
apis.push(api);
}
}
return result;
};
}
};

View File

@ -380,7 +380,27 @@ function NewAqlReplaceORWithINTestSuite () {
assertEqual(executeWithRule(query, {}), executeWithoutRule(query, {}));
assertEqual(expected, executeWithoutRule(query, {}));
},
testFiresRand: function () {
var query = "LET a = RAND(), b = RAND() FOR i IN [1,2,3,4,5] "
+ "FILTER i.a.b == a || i.a.b == b RETURN i";
isRuleUsed(query, {});
},
testFiresCommonConstant: function () {
var query = "LET x = {a:@a} FOR v IN " + replace.name()
+ " FILTER x.a == v.value || x.a == v._key RETURN v._key";
var key = replace.any()._key;
isRuleUsed(query, {a: key});
var actual = getQueryResults(query, {a: key});
assertEqual(key, actual.toString());
},
testDudAlwaysTrue: function () {
var query =
"FOR x IN " + replace.name()