1
0
Fork 0

issue #1069: Add 'raw' link to swagger ui so that the raw swagger json can easily be retrieved

This adds a link to the Swagger API docs to an application's detail view in
  the **Applications** tab of the web interface. The link produces the Swagger
  JSON directly. If authentication is turned on, the link requires authentication,
  too.

Conflicts:
	CHANGELOG
This commit is contained in:
Jan Steemann 2014-11-04 01:16:56 +01:00
parent e0a379673b
commit 358c596b0e
4 changed files with 55 additions and 7 deletions

View File

@ -1,5 +1,23 @@
v2.3.0-beta1 (2014-11-01) v2.3.0 (XXXX-XX-XX)
------------------------- -------------------
* fixed issue #1075: Aardvark: user name required even if auth is off #1075
The fix for this prefills the username input field with the current user's
accout name if any and `root` (the default username) otherwise. Additionally,
the tooltip text has been slightly adjusted.
* fixed issue #1069: Add 'raw' link to swagger ui so that the raw swagger
json can easily be retrieved
This adds a link to the Swagger API docs to an application's detail view in
the **Applications** tab of the web interface. The link produces the Swagger
JSON directly. If authentication is turned on, the link requires authentication,
too.
v2.3.0-beta (2014-11-01)
------------------------
* added dedicated `NOT IN` operator for AQL * added dedicated `NOT IN` operator for AQL

View File

@ -282,16 +282,17 @@ controller.get('/docus', function (req, res) {
+ " foxxes and supplies the paths for the swagger documentation"); + " foxxes and supplies the paths for the swagger documentation");
/** Get Documentation for one Foxx /** Get Documentation for one Foxx
* *
* Get the complete documentation availabloe for one Foxx * Get the complete documentation available for one Foxx
* *
*/ */
controller.get("/docu/:key",function (req, res) { controller.get("/docu/:key",function (req, res) {
var subPath = req.path.substr(0, req.path.lastIndexOf("[") - 1), var subPath = req.path.substr(0, req.path.lastIndexOf("[") - 1),
key = req.params("key"), key = req.params("key"),
path = req.protocol + "://" + req.headers.host + "/_db/" + req.database + subPath + "/" + key + "/"; path = req.protocol + "://" + req.headers.host +
"/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(key) + "/";
res.json(docus.listOne(path, key)); res.json(docus.listOne(path, key));
}).summary("List documentation of all foxxes.") }).summary("List documentation of one foxxes.")
.notes("This function simply returns one specific" .notes("This function simply returns one specific"
+ " foxx and supplies the paths for the swagger documentation"); + " foxx and supplies the paths for the swagger documentation");
@ -309,6 +310,27 @@ controller.get('/docu/:key/*', function(req, res) {
}).summary("List the API for one foxx") }).summary("List the API for one foxx")
.notes("This function lists the API of the foxx" .notes("This function lists the API of the foxx"
+ " running under the given mount point"); + " running under the given mount point");
/** Subroutes for API Documentation
*
* Get the Elements of the API Documentation subroutes
*
*/
controller.get('/swagger/:mount', function(req, res) {
var subPath = req.path.substr(0, req.path.lastIndexOf("[") - 1),
mount = decodeURIComponent(req.params("mount")),
path = req.protocol + "://" + req.headers.host +
"/_db/" + encodeURIComponent(req.database) + subPath + "/" + encodeURIComponent(mount) + "/",
candidate = db._aal.firstExample({ mount: mount });
if (candidate === null) {
throw "no entry found for mount";
}
res.json(docus.show(mount));
// res.json(docus.listOneForMount(path, mount));
}).summary("Returns the generated Swagger JSON description for one foxx")
.notes("This function returns the Swagger JSON API description of the foxx"
+ " running under the given mount point");
/** Move Foxx to other Mount /** Move Foxx to other Mount
* *

View File

@ -12,8 +12,8 @@
<th class="collectionTh"><strong><%=appInfos[1] %></strong></th> <th class="collectionTh"><strong><%=appInfos[1] %></strong></th>
</tr> </tr>
<tr> <tr>
<th class="collectionTh">&nbsp;</th> <th class="collectionTh">Documentation:</th>
<th class="collectionTh">&nbsp;</th> <th class="collectionTh"><%=documentationJsonUrl</th>
</tr> </tr>
<tr> <tr>
<th class="collectionTh">Mount:</th> <th class="collectionTh">Mount:</th>

View File

@ -100,6 +100,14 @@
list.push(modView.createReadOnlyEntry( list.push(modView.createReadOnlyEntry(
"id_name", "Name", name "id_name", "Name", name
)); ));
var link = window.location.origin +
"/_db/" + encodeURIComponent(arangoHelper.currentDatabase()) +
"/_admin/aardvark/swagger/" + encodeURIComponent(encodeURIComponent(this.model.get("mount")));
list.push(modView.createReadOnlyEntry(
"id_documentationJsonUrl",
"API docs",
"<a href=\"" + link + "\">Link to JSON</a>"
));
if (editable) { if (editable) {
list.push(modView.createTextEntry( list.push(modView.createTextEntry(
"change-mount-point", "Mount", this.model.get("mount"), "change-mount-point", "Mount", this.model.get("mount"),