aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js')
-rw-r--r--MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js889
1 files changed, 785 insertions, 104 deletions
diff --git a/MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js b/MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js
index 4cdcc3976..93cd0bea4 100644
--- a/MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js
+++ b/MediaBrowser.Server.Implementations/swagger-ui/swagger-ui.js
@@ -65,7 +65,15 @@ function clippyCopiedCallback(a) {
function log() {
if (window.console) console.log.apply(console,arguments);
}
-
+// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
+if (Function.prototype.bind && console && typeof console.log == "object") {
+ [
+ "log","info","warn","error","assert","dir","clear","profile","profileEnd"
+ ].forEach(function (method) {
+ console[method] = this.bind(console[method], console);
+ }, Function.prototype.call);
+}
+
var Docs = {
shebang: function() {
@@ -107,7 +115,7 @@ var Docs = {
},
toggleEndpointListForResource: function(resource) {
- var elem = $('li#resource_' + resource + ' ul.endpoints');
+ var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
if (elem.is(':visible')) {
Docs.collapseEndpointListForResource(resource);
} else {
@@ -117,7 +125,13 @@ var Docs = {
// Expand resource
expandEndpointListForResource: function(resource) {
- $('#resource_' + resource).addClass('active');
+ var resource = Docs.escapeResourceName(resource);
+ if (resource == '') {
+ $('.resource ul.endpoints').slideDown();
+ return;
+ }
+
+ $('li#resource_' + resource).addClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideDown();
@@ -125,7 +139,8 @@ var Docs = {
// Collapse resource and mark as explicitly closed
collapseEndpointListForResource: function(resource) {
- $('#resource_' + resource).removeClass('active');
+ var resource = Docs.escapeResourceName(resource);
+ $('li#resource_' + resource).removeClass('active');
var elem = $('li#resource_' + resource + ' ul.endpoints');
elem.slideUp();
@@ -134,7 +149,13 @@ var Docs = {
expandOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
- $('li#resource_' + resource + ' li.operation div.content').each(function() {
+
+ if (resource == '') {
+ $('.resource ul.endpoints li.operation div.content').slideDown();
+ return;
+ }
+
+ $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.expandOperation($(this));
});
},
@@ -142,11 +163,16 @@ var Docs = {
collapseOperationsForResource: function(resource) {
// Make sure the resource container is open..
Docs.expandEndpointListForResource(resource);
- $('li#resource_' + resource + ' li.operation div.content').each(function() {
+
+ $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
Docs.collapseOperation($(this));
});
},
+ escapeResourceName: function(resource) {
+ return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
+ },
+
expandOperation: function(elem) {
elem.slideDown();
},
@@ -155,19 +181,96 @@ var Docs = {
elem.slideUp();
}
-};(function() {
+};
+(function() {
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0;
+
+function program1(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.produces;
+ stack1 = foundHelper || depth0.produces;
+ stack2 = helpers.each;
+ tmp1 = self.program(2, program2, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n";
+ return buffer;}
+function program2(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <option value=\"";
+ stack1 = depth0;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\">";
+ stack1 = depth0;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "this", { hash: {} }); }
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "</option>\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+
+ return "\n <option value=\"application/json\">application/json</option>\n";}
+
+ buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
+ foundHelper = helpers.produces;
+ stack1 = foundHelper || depth0.produces;
+ stack2 = helpers['if'];
+ tmp1 = self.program(1, program1, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(4, program4, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n</select>\n";
+ return buffer;});
+})();
+
+(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) {
helpers = helpers || Handlebars.helpers;
- var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+ var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+function program1(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
+ foundHelper = helpers.apiVersion;
+ stack1 = foundHelper || depth0.apiVersion;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "apiVersion", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "\n ";
+ return buffer;}
- buffer += "\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[<span style=\"font-variant: small-caps\">base url</span>: ";
+ buffer += "\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
foundHelper = helpers.basePath;
stack1 = foundHelper || depth0.basePath;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "basePath", { hash: {} }); }
- buffer += escapeExpression(stack1) + "]</h4>\n </div>\n</div>";
+ buffer += escapeExpression(stack1) + "\n ";
+ foundHelper = helpers.apiVersion;
+ stack1 = foundHelper || depth0.apiVersion;
+ stack2 = helpers['if'];
+ tmp1 = self.program(1, program1, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "]</h4>\n </div>\n</div>\n";
return buffer;});
})();
@@ -192,14 +295,29 @@ function program1(depth0,data) {
function program3(depth0,data) {
- return "\n ";}
+ return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"content-type\" />\n ";}
function program5(depth0,data) {
- return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='http://swagger.wordnik.com/images/throbber.gif' style='display:none' />\n </div>\n ";}
+ return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\" >Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 320px; max-width: 330px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";}
+
+function program7(depth0,data) {
+
+
+ return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";}
+
+function program9(depth0,data) {
+
+
+ return "\n ";}
- buffer += "\n <ul class='operations' >\n <li class='";
+function program11(depth0,data) {
+
+
+ return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";}
+
+ buffer += "\n <ul class='operations' >\n <li class='";
foundHelper = helpers.httpMethod;
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -219,6 +337,11 @@ function program5(depth0,data) {
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "_";
+ foundHelper = helpers.number;
+ stack1 = foundHelper || depth0.number;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
buffer += escapeExpression(stack1) + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
foundHelper = helpers.resourceName;
stack1 = foundHelper || depth0.resourceName;
@@ -234,6 +357,11 @@ function program5(depth0,data) {
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "_";
+ foundHelper = helpers.number;
+ stack1 = foundHelper || depth0.number;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
buffer += escapeExpression(stack1) + "' class=\"toggleOperation\">";
foundHelper = helpers.httpMethod;
stack1 = foundHelper || depth0.httpMethod;
@@ -254,12 +382,17 @@ function program5(depth0,data) {
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "_";
+ foundHelper = helpers.number;
+ stack1 = foundHelper || depth0.number;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
buffer += escapeExpression(stack1) + "' class=\"toggleOperation\">";
- foundHelper = helpers.pathJson;
- stack1 = foundHelper || depth0.pathJson;
+ foundHelper = helpers.path;
+ stack1 = foundHelper || depth0.path;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
- else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "pathJson", { hash: {} }); }
- buffer += escapeExpression(stack1) + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "path", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
foundHelper = helpers.resourceName;
stack1 = foundHelper || depth0.resourceName;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -274,6 +407,11 @@ function program5(depth0,data) {
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "_";
+ foundHelper = helpers.number;
+ stack1 = foundHelper || depth0.number;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
buffer += escapeExpression(stack1) + "' class=\"toggleOperation\">";
foundHelper = helpers.summary;
stack1 = foundHelper || depth0.summary;
@@ -295,6 +433,11 @@ function program5(depth0,data) {
stack1 = foundHelper || depth0.httpMethod;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "httpMethod", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "_";
+ foundHelper = helpers.number;
+ stack1 = foundHelper || depth0.number;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "number", { hash: {} }); }
buffer += escapeExpression(stack1) + "_content' style='display:none'>\n ";
foundHelper = helpers.notes;
stack1 = foundHelper || depth0.notes;
@@ -305,14 +448,44 @@ function program5(depth0,data) {
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n <form accept-charset='UTF-8' action='#' class='sandbox' method='post'>\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>Parameter</th>\n <th>Value</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
+ buffer += "\n ";
+ foundHelper = helpers.responseClass;
+ stack1 = foundHelper || depth0.responseClass;
+ stack2 = helpers['if'];
+ tmp1 = self.program(3, program3, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
+ foundHelper = helpers.parameters;
+ stack1 = foundHelper || depth0.parameters;
+ stack2 = helpers['if'];
+ tmp1 = self.program(5, program5, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ foundHelper = helpers.errorResponses;
+ stack1 = foundHelper || depth0.errorResponses;
+ stack2 = helpers['if'];
+ tmp1 = self.program(7, program7, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.noop;
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
foundHelper = helpers.isReadOnly;
stack1 = foundHelper || depth0.isReadOnly;
stack2 = helpers['if'];
- tmp1 = self.program(3, program3, data);
+ tmp1 = self.program(9, program9, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(5, program5, data);
+ tmp1.inverse = self.program(11, program11, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
@@ -329,8 +502,8 @@ function program1(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n ";
- foundHelper = helpers.defaultValue;
- stack1 = foundHelper || depth0.defaultValue;
+ foundHelper = helpers.isFile;
+ stack1 = foundHelper || depth0.isFile;
stack2 = helpers['if'];
tmp1 = self.program(2, program2, data);
tmp1.hash = {};
@@ -338,12 +511,38 @@ function program1(depth0,data) {
tmp1.inverse = self.program(4, program4, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n \n ";
+ buffer += "\n ";
return buffer;}
function program2(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <textarea class='body-textarea' name='";
+ buffer += "\n <input type=\"file\" name='";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'/>\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(5, program5, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(7, program7, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program5(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <textarea class='body-textarea' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -353,39 +552,39 @@ function program2(depth0,data) {
stack1 = foundHelper || depth0.defaultValue;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
- buffer += escapeExpression(stack1) + "</textarea>\n ";
+ buffer += escapeExpression(stack1) + "</textarea>\n ";
return buffer;}
-function program4(depth0,data) {
+function program7(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <textarea class='body-textarea' name='";
+ buffer += "\n <textarea class='body-textarea' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + "'></textarea>\n ";
+ buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"content-type\" />\n ";
return buffer;}
-function program6(depth0,data) {
+function program9(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n ";
foundHelper = helpers.defaultValue;
stack1 = foundHelper || depth0.defaultValue;
stack2 = helpers['if'];
- tmp1 = self.program(7, program7, data);
+ tmp1 = self.program(10, program10, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(9, program9, data);
+ tmp1.inverse = self.program(12, program12, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;}
-function program7(depth0,data) {
+function program10(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <input minlength='0' name='";
+ buffer += "\n <input class='parameter' minlength='0' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -398,10 +597,10 @@ function program7(depth0,data) {
buffer += escapeExpression(stack1) + "'/>\n ";
return buffer;}
-function program9(depth0,data) {
+function program12(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <input minlength='0' name='";
+ buffer += "\n <input class='parameter' minlength='0' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -414,23 +613,23 @@ function program9(depth0,data) {
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + "</td>\n<td>\n \n ";
+ buffer += escapeExpression(stack1) + "</td>\n<td>\n\n ";
foundHelper = helpers.isBody;
stack1 = foundHelper || depth0.isBody;
stack2 = helpers['if'];
tmp1 = self.program(1, program1, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(6, program6, data);
+ tmp1.inverse = self.program(9, program9, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n\n</td>\n<td width='500'>";
+ buffer += "\n\n</td>\n<td>";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "</td>\n\n";
+ buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n\n";
return buffer;});
})();
@@ -522,7 +721,7 @@ function program11(depth0,data) {
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + "</td>\n<td>\n <select name='";
+ buffer += escapeExpression(stack1) + "</td>\n<td>\n <select class='parameter' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -548,13 +747,13 @@ function program11(depth0,data) {
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n </select>\n</td>\n<td width='500'>";
+ buffer += "\n </select>\n</td>\n<td>";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "</td>\n\n";
+ buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
return buffer;});
})();
@@ -582,15 +781,35 @@ function program1(depth0,data) {
function program3(depth0,data) {
- var buffer = "", stack1;
+ var buffer = "", stack1, stack2;
buffer += "\n ";
foundHelper = helpers.defaultValue;
stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(4, program4, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(6, program6, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program4(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
- buffer += escapeExpression(stack1) + "\n ";
+ buffer += escapeExpression(stack1) + "\n ";
return buffer;}
+function program6(depth0,data) {
+
+
+ return "\n (empty)\n ";}
+
buffer += "<td class='code'>";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
@@ -606,13 +825,13 @@ function program3(depth0,data) {
tmp1.inverse = self.program(3, program3, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n</td>\n<td width='500'>";
+ buffer += "\n</td>\n<td>";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "</td>\n\n";
+ buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
return buffer;});
})();
@@ -640,15 +859,35 @@ function program1(depth0,data) {
function program3(depth0,data) {
- var buffer = "", stack1;
+ var buffer = "", stack1, stack2;
buffer += "\n ";
foundHelper = helpers.defaultValue;
stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(4, program4, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(6, program6, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program4(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
- buffer += escapeExpression(stack1) + "\n ";
+ buffer += escapeExpression(stack1) + "\n ";
return buffer;}
+function program6(depth0,data) {
+
+
+ return "\n (empty)\n ";}
+
buffer += "<td class='code required'>";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
@@ -664,13 +903,13 @@ function program3(depth0,data) {
tmp1.inverse = self.program(3, program3, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n</td>\n<td width='500'>";
+ buffer += "\n</td>\n<td>";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "</td>\n";
+ buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
return buffer;});
})();
@@ -684,8 +923,8 @@ function program1(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n ";
- foundHelper = helpers.defaultValue;
- stack1 = foundHelper || depth0.defaultValue;
+ foundHelper = helpers.isFile;
+ stack1 = foundHelper || depth0.isFile;
stack2 = helpers['if'];
tmp1 = self.program(2, program2, data);
tmp1.hash = {};
@@ -693,12 +932,38 @@ function program1(depth0,data) {
tmp1.inverse = self.program(4, program4, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n \n ";
+ buffer += "\n ";
return buffer;}
function program2(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
+ buffer += "\n <input type=\"file\" name='";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'/>\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(5, program5, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(7, program7, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program5(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -708,39 +973,65 @@ function program2(depth0,data) {
stack1 = foundHelper || depth0.defaultValue;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
- buffer += escapeExpression(stack1) + "</textarea>\n ";
+ buffer += escapeExpression(stack1) + "</textarea>\n ";
return buffer;}
-function program4(depth0,data) {
+function program7(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
+ buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + "'></textarea>\n ";
+ buffer += escapeExpression(stack1) + "'></textarea>\n <br />\n <div class=\"content-type\" />\n ";
return buffer;}
-function program6(depth0,data) {
+function program9(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n ";
+ foundHelper = helpers.isFile;
+ stack1 = foundHelper || depth0.isFile;
+ stack2 = helpers['if'];
+ tmp1 = self.program(10, program10, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(12, program12, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program10(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n <input class='parameter' class='required' type='file' name='";
+ foundHelper = helpers.name;
+ stack1 = foundHelper || depth0.name;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "'/>\n ";
+ return buffer;}
+
+function program12(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
foundHelper = helpers.defaultValue;
stack1 = foundHelper || depth0.defaultValue;
stack2 = helpers['if'];
- tmp1 = self.program(7, program7, data);
+ tmp1 = self.program(13, program13, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(9, program9, data);
+ tmp1.inverse = self.program(15, program15, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n ";
+ buffer += "\n ";
return buffer;}
-function program7(depth0,data) {
+function program13(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <input class='required' minlength='1' name='";
+ buffer += "\n <input class='parameter required' minlength='1' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -750,18 +1041,18 @@ function program7(depth0,data) {
stack1 = foundHelper || depth0.defaultValue;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
- buffer += escapeExpression(stack1) + "'/>\n ";
+ buffer += escapeExpression(stack1) + "'/>\n ";
return buffer;}
-function program9(depth0,data) {
+function program15(depth0,data) {
var buffer = "", stack1;
- buffer += "\n <input class='required' minlength='1' name='";
+ buffer += "\n <input class='parameter required' minlength='1' name='";
foundHelper = helpers.name;
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + "' placeholder='(required)' type='text' value=''/>\n ";
+ buffer += escapeExpression(stack1) + "' placeholder='(required)' type='text' value=''/>\n ";
return buffer;}
buffer += "<td class='code required'>";
@@ -776,16 +1067,16 @@ function program9(depth0,data) {
tmp1 = self.program(1, program1, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(6, program6, data);
+ tmp1.inverse = self.program(9, program9, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n</td>\n<td width='500'>\n <strong>";
+ buffer += "\n</td>\n<td>\n <strong>";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "</strong>\n</td>\n";
+ buffer += "</strong>\n</td>\n<td><span class=\"model-signature\"></span></td>\n";
return buffer;});
})();
@@ -850,11 +1141,55 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
return buffer;});
})();
+(function() {
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+
+ buffer += "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
+ foundHelper = helpers.signature;
+ stack1 = foundHelper || depth0.signature;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "signature", { hash: {} }); }
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
+ foundHelper = helpers.sampleJSON;
+ stack1 = foundHelper || depth0.sampleJSON;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "sampleJSON", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
+ return buffer;});
+})();
-// Generated by CoffeeScript 1.3.3
(function() {
- var HeaderView, MainView, OperationView, ParameterView, ResourceView, SwaggerUi,
+ var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
+templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) {
+ helpers = helpers || Handlebars.helpers;
+ var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression;
+
+
+ buffer += "<td width='15%' class='code'>";
+ foundHelper = helpers.code;
+ stack1 = foundHelper || depth0.code;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "code", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "</td>\n<td>";
+ foundHelper = helpers.reason;
+ stack1 = foundHelper || depth0.reason;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "reason", { hash: {} }); }
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "</td>\n\n";
+ return buffer;});
+})();
+
+
+
+// Generated by CoffeeScript 1.4.0
+(function() {
+ var ContentTypeView, HeaderView, MainView, OperationView, ParameterView, ResourceView, SignatureView, StatusCodeView, SwaggerUi,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
@@ -866,10 +1201,6 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
return SwaggerUi.__super__.constructor.apply(this, arguments);
}
- SwaggerUi.prototype.routes = {
- '': 'load'
- };
-
SwaggerUi.prototype.dom_id = "swagger_ui";
SwaggerUi.prototype.options = null;
@@ -922,10 +1253,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
_ref.clear();
}
this.headerView.update(this.options.discoveryUrl, this.options.apiKey);
- this.api = new SwaggerApi(this.options);
- return Backbone.history.start({
- pushState: true
- });
+ return this.api = new SwaggerApi(this.options);
};
SwaggerUi.prototype.render = function() {
@@ -936,6 +1264,16 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
el: $('#' + this.dom_id)
}).render();
this.showMessage();
+ switch (this.options.docExpansion) {
+ case "full":
+ Docs.expandOperationsForResource('');
+ break;
+ case "list":
+ Docs.collapseOperationsForResource('');
+ }
+ if (this.options.onComplete) {
+ this.options.onComplete(this.api, this);
+ }
return setTimeout(function() {
return Docs.shebang();
}, 400);
@@ -951,12 +1289,17 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
};
SwaggerUi.prototype.onLoadFailure = function(data) {
+ var val;
if (data == null) {
data = '';
}
$('#message-bar').removeClass('message-success');
$('#message-bar').addClass('message-fail');
- return $('#message-bar').html(data);
+ val = $('#message-bar').html(data);
+ if (this.options.onFailure != null) {
+ this.options.onFailure(data);
+ }
+ return val;
};
return SwaggerUi;
@@ -985,7 +1328,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
HeaderView.prototype.showPetStore = function(e) {
return this.trigger('update-swagger-ui', {
- discoveryUrl: "http://petstore.swagger.wordnik.com/api/resources.json",
+ discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json",
apiKey: "special-key"
});
};
@@ -1044,7 +1387,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
MainView.prototype.render = function() {
var resource, _i, _len, _ref;
$(this.el).html(Handlebars.templates.main(this.model));
- _ref = this.model.resourcesArray;
+ _ref = this.model.apisArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
resource = _ref[_i];
this.addResource(resource);
@@ -1084,6 +1427,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
ResourceView.prototype.render = function() {
var operation, _i, _len, _ref;
$(this.el).html(Handlebars.templates.resource(this.model));
+ this.number = 0;
_ref = this.model.operationsArray;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
operation = _ref[_i];
@@ -1094,12 +1438,14 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
ResourceView.prototype.addOperation = function(operation) {
var operationView;
+ operation.number = this.number;
operationView = new OperationView({
model: operation,
tagName: 'li',
className: 'endpoint'
});
- return $('.endpoints', $(this.el)).append(operationView.render().el);
+ $('.endpoints', $(this.el)).append(operationView.render().el);
+ return this.number++;
};
return ResourceView;
@@ -1115,6 +1461,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
}
OperationView.prototype.events = {
+ 'submit .sandbox': 'submitOperation',
'click .submit': 'submitOperation',
'click .response_hider': 'hideResponse',
'click .toggleOperation': 'toggleOperationContent'
@@ -1123,17 +1470,49 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
OperationView.prototype.initialize = function() {};
OperationView.prototype.render = function() {
- var isMethodSubmissionSupported, param, _i, _len, _ref;
+ var contentTypeModel, contentTypeView, isMethodSubmissionSupported, param, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
isMethodSubmissionSupported = jQuery.inArray(this.model.httpMethod, this.model.supportedSubmitMethods()) >= 0;
if (!isMethodSubmissionSupported) {
this.model.isReadOnly = true;
}
$(this.el).html(Handlebars.templates.operation(this.model));
+ if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
+ signatureModel = {
+ sampleJSON: this.model.responseSampleJSON,
+ isParam: false,
+ signature: this.model.responseClassSignature
+ };
+ responseSignatureView = new SignatureView({
+ model: signatureModel,
+ tagName: 'div'
+ });
+ $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
+ } else {
+ $('.model-signature', $(this.el)).html(this.model.responseClass);
+ }
+ contentTypeModel = {
+ isParam: false
+ };
+ if (this.model.supportedContentTypes) {
+ contentTypeModel.produces = this.model.supportedContentTypes;
+ }
+ if (this.model.produces) {
+ contentTypeModel.produces = this.model.produces;
+ }
+ contentTypeView = new ContentTypeView({
+ model: contentTypeModel
+ });
+ $('.content-type', $(this.el)).append(contentTypeView.render().el);
_ref = this.model.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
this.addParameter(param);
}
+ _ref1 = this.model.errorResponses;
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ statusCode = _ref1[_j];
+ this.addStatusCode(statusCode);
+ }
return this;
};
@@ -1147,9 +1526,21 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
return $('.operation-params', $(this.el)).append(paramView.render().el);
};
- OperationView.prototype.submitOperation = function() {
- var bodyParam, error_free, form, headerParams, invocationUrl, map, o, obj, param, _i, _j, _len, _len1, _ref, _ref1,
+ OperationView.prototype.addStatusCode = function(statusCode) {
+ var statusCodeView;
+ statusCodeView = new StatusCodeView({
+ model: statusCode,
+ tagName: 'tr'
+ });
+ return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
+ };
+
+ OperationView.prototype.submitOperation = function(e) {
+ var bodyParam, consumes, error_free, form, headerParams, invocationUrl, isFileUpload, isFormPost, map, o, obj, param, paramContentTypeField, responseContentTypeField, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4,
_this = this;
+ if (e != null) {
+ e.preventDefault();
+ }
form = $('.sandbox', $(this.el));
error_free = true;
form.find("input.required").each(function() {
@@ -1174,12 +1565,56 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
map[o.name] = o.value;
}
}
- bodyParam = null;
- _ref1 = this.model.parameters;
- for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
- param = _ref1[_j];
- if (param.paramType === 'body') {
- bodyParam = map[param.name];
+ isFileUpload = form.children().find('input[type~="file"]').size() !== 0;
+ isFormPost = false;
+ consumes = "application/json";
+ if (this.model.consumes && this.model.consumes.length > 0) {
+ consumes = this.model.consumes[0];
+ } else {
+ _ref1 = this.model.parameters;
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ o = _ref1[_j];
+ if (o.paramType === 'form') {
+ isFormPost = true;
+ consumes = false;
+ }
+ }
+ if (isFileUpload) {
+ consumes = false;
+ } else if (this.model.httpMethod.toLowerCase() === "post" && isFormPost === false) {
+ consumes = "application/json";
+ }
+ }
+ if (isFileUpload) {
+ bodyParam = new FormData();
+ _ref2 = this.model.parameters;
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
+ param = _ref2[_k];
+ if ((param.paramType === 'body' || 'form') && param.name !== 'file' && (map[param.name] != null)) {
+ bodyParam.append(param.name, map[param.name]);
+ }
+ }
+ $.each(form.children().find('input[type~="file"]'), function(i, el) {
+ return bodyParam.append($(el).attr('name'), el.files[0]);
+ });
+ console.log(bodyParam);
+ } else if (isFormPost) {
+ bodyParam = new FormData();
+ _ref3 = this.model.parameters;
+ for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
+ param = _ref3[_l];
+ if (map[param.name] != null) {
+ bodyParam.append(param.name, map[param.name]);
+ }
+ }
+ } else {
+ bodyParam = null;
+ _ref4 = this.model.parameters;
+ for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
+ param = _ref4[_m];
+ if (param.paramType === 'body') {
+ bodyParam = map[param.name];
+ }
}
}
log("bodyParam = " + bodyParam);
@@ -1193,7 +1628,9 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
url: invocationUrl,
headers: headerParams,
data: bodyParam,
+ contentType: consumes,
dataType: 'json',
+ processData: false,
error: function(xhr, textStatus, error) {
return _this.showErrorStatus(xhr, textStatus, error);
},
@@ -1204,10 +1641,22 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
return _this.showCompleteStatus(data);
}
};
- if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
- obj.contentType = "application/json";
+ paramContentTypeField = $("td select[name=contentType]", $(this.el)).val();
+ if (paramContentTypeField) {
+ obj.contentType = paramContentTypeField;
}
- return jQuery.ajax(obj);
+ log('content type = ' + obj.contentType);
+ if (!obj.data || (obj.type === 'GET' || obj.type === 'DELETE')) {
+ obj.contentType = false;
+ }
+ log('content type is now = ' + obj.contentType);
+ responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(this.el)).val();
+ if (responseContentTypeField) {
+ obj.headers = obj.headers != null ? obj.headers : {};
+ obj.headers.accept = responseContentTypeField;
+ }
+ jQuery.ajax(obj);
+ return false;
}
};
@@ -1222,7 +1671,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
OperationView.prototype.showResponse = function(response) {
var prettyJson;
prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
- return $(".response_body", $(this.el)).html(prettyJson);
+ return $(".response_body", $(this.el)).html(escape(prettyJson));
};
OperationView.prototype.showErrorStatus = function(data) {
@@ -1233,24 +1682,101 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
return this.showStatus(data);
};
+ OperationView.prototype.formatXml = function(xml) {
+ var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
+ reg = /(>)(<)(\/*)/g;
+ wsexp = /[ ]*(.*)[ ]+\n/g;
+ contexp = /(<.+>)(.+\n)/g;
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
+ pad = 0;
+ formatted = '';
+ lines = xml.split('\n');
+ indent = 0;
+ lastType = 'other';
+ transitions = {
+ 'single->single': 0,
+ 'single->closing': -1,
+ 'single->opening': 0,
+ 'single->other': 0,
+ 'closing->single': 0,
+ 'closing->closing': -1,
+ 'closing->opening': 0,
+ 'closing->other': 0,
+ 'opening->single': 1,
+ 'opening->closing': 0,
+ 'opening->opening': 1,
+ 'opening->other': 1,
+ 'other->single': 0,
+ 'other->closing': -1,
+ 'other->opening': 0,
+ 'other->other': 0
+ };
+ _fn = function(ln) {
+ var fromTo, j, key, padding, type, types, value;
+ types = {
+ single: Boolean(ln.match(/<.+\/>/)),
+ closing: Boolean(ln.match(/<\/.+>/)),
+ opening: Boolean(ln.match(/<[^!?].*>/))
+ };
+ type = ((function() {
+ var _results;
+ _results = [];
+ for (key in types) {
+ value = types[key];
+ if (value) {
+ _results.push(key);
+ }
+ }
+ return _results;
+ })())[0];
+ type = type === void 0 ? 'other' : type;
+ fromTo = lastType + '->' + type;
+ lastType = type;
+ padding = '';
+ indent += transitions[fromTo];
+ padding = ((function() {
+ var _j, _ref, _results;
+ _results = [];
+ for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
+ _results.push(' ');
+ }
+ return _results;
+ })()).join('');
+ if (fromTo === 'opening->closing') {
+ return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
+ } else {
+ return formatted += padding + ln + '\n';
+ }
+ };
+ for (_i = 0, _len = lines.length; _i < _len; _i++) {
+ ln = lines[_i];
+ _fn(ln);
+ }
+ return formatted;
+ };
+
OperationView.prototype.showStatus = function(data) {
- var response_body;
+ var code, pre, response_body;
try {
- response_body = "<pre>" + JSON.stringify(JSON.parse(data.responseText), null, 2).replace(/\n/g, "<br>") + "</pre>";
+ code = $('<code />').text(JSON.stringify(JSON.parse(data.responseText), null, 2));
+ pre = $('<pre class="json" />').append(code);
} catch (error) {
- response_body = "<span style='color:red'>&nbsp;&nbsp;&nbsp;[unable to parse as json; raw response below]</span><br><pre>" + data.responseText + "</pre>";
+ code = $('<code />').text(this.formatXml(data.responseText));
+ pre = $('<pre class="xml" />').append(code);
}
+ response_body = pre;
$(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
$(".response_body", $(this.el)).html(response_body);
$(".response_headers", $(this.el)).html("<pre>" + data.getAllResponseHeaders() + "</pre>");
$(".response", $(this.el)).slideDown();
$(".response_hider", $(this.el)).show();
- return $(".response_throbber", $(this.el)).hide();
+ $(".response_throbber", $(this.el)).hide();
+ return hljs.highlightBlock($('.response_body', $(this.el))[0]);
};
OperationView.prototype.toggleOperationContent = function() {
var elem;
- elem = $('#' + this.model.resourceName + "_" + this.model.nickname + "_" + this.model.httpMethod + "_content");
+ elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.httpMethod + "_" + this.model.number + "_content");
if (elem.is(':visible')) {
return Docs.collapseOperation(elem);
} else {
@@ -1262,6 +1788,31 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
})(Backbone.View);
+ StatusCodeView = (function(_super) {
+
+ __extends(StatusCodeView, _super);
+
+ function StatusCodeView() {
+ return StatusCodeView.__super__.constructor.apply(this, arguments);
+ }
+
+ StatusCodeView.prototype.initialize = function() {};
+
+ StatusCodeView.prototype.render = function() {
+ var template;
+ template = this.template();
+ $(this.el).html(template(this.model));
+ return this;
+ };
+
+ StatusCodeView.prototype.template = function() {
+ return Handlebars.templates.status_code;
+ };
+
+ return StatusCodeView;
+
+ })(Backbone.View);
+
ParameterView = (function(_super) {
__extends(ParameterView, _super);
@@ -1273,12 +1824,42 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
ParameterView.prototype.initialize = function() {};
ParameterView.prototype.render = function() {
- var template;
+ var contentTypeModel, contentTypeView, signatureModel, signatureView, template;
if (this.model.paramType === 'body') {
this.model.isBody = true;
}
+ if (this.model.dataType === 'file') {
+ this.model.isFile = true;
+ }
template = this.template();
$(this.el).html(template(this.model));
+ signatureModel = {
+ sampleJSON: this.model.sampleJSON,
+ isParam: true,
+ signature: this.model.signature
+ };
+ if (this.model.sampleJSON) {
+ signatureView = new SignatureView({
+ model: signatureModel,
+ tagName: 'div'
+ });
+ $('.model-signature', $(this.el)).append(signatureView.render().el);
+ } else {
+ $('.model-signature', $(this.el)).html(this.model.signature);
+ }
+ contentTypeModel = {
+ isParam: false
+ };
+ if (this.model.supportedContentTypes) {
+ contentTypeModel.produces = this.model.supportedContentTypes;
+ }
+ if (this.model.produces) {
+ contentTypeModel.produces = this.model.produces;
+ }
+ contentTypeView = new ContentTypeView({
+ model: contentTypeModel
+ });
+ $('.content-type', $(this.el)).append(contentTypeView.render().el);
return this;
};
@@ -1306,4 +1887,104 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
})(Backbone.View);
+ SignatureView = (function(_super) {
+
+ __extends(SignatureView, _super);
+
+ function SignatureView() {
+ return SignatureView.__super__.constructor.apply(this, arguments);
+ }
+
+ SignatureView.prototype.events = {
+ 'click a.description-link': 'switchToDescription',
+ 'click a.snippet-link': 'switchToSnippet',
+ 'mousedown .snippet': 'snippetToTextArea'
+ };
+
+ SignatureView.prototype.initialize = function() {};
+
+ SignatureView.prototype.render = function() {
+ var template;
+ template = this.template();
+ $(this.el).html(template(this.model));
+ this.switchToDescription();
+ this.isParam = this.model.isParam;
+ if (this.isParam) {
+ $('.notice', $(this.el)).text('Click to set as parameter value');
+ }
+ return this;
+ };
+
+ SignatureView.prototype.template = function() {
+ return Handlebars.templates.signature;
+ };
+
+ SignatureView.prototype.switchToDescription = function(e) {
+ if (e != null) {
+ e.preventDefault();
+ }
+ $(".snippet", $(this.el)).hide();
+ $(".description", $(this.el)).show();
+ $('.description-link', $(this.el)).addClass('selected');
+ return $('.snippet-link', $(this.el)).removeClass('selected');
+ };
+
+ SignatureView.prototype.switchToSnippet = function(e) {
+ if (e != null) {
+ e.preventDefault();
+ }
+ $(".description", $(this.el)).hide();
+ $(".snippet", $(this.el)).show();
+ $('.snippet-link', $(this.el)).addClass('selected');
+ return $('.description-link', $(this.el)).removeClass('selected');
+ };
+
+ SignatureView.prototype.snippetToTextArea = function(e) {
+ var textArea;
+ if (this.isParam) {
+ if (e != null) {
+ e.preventDefault();
+ }
+ textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
+ if ($.trim(textArea.val()) === '') {
+ return textArea.val(this.model.sampleJSON);
+ }
+ }
+ };
+
+ return SignatureView;
+
+ })(Backbone.View);
+
+ ContentTypeView = (function(_super) {
+
+ __extends(ContentTypeView, _super);
+
+ function ContentTypeView() {
+ return ContentTypeView.__super__.constructor.apply(this, arguments);
+ }
+
+ ContentTypeView.prototype.initialize = function() {};
+
+ ContentTypeView.prototype.render = function() {
+ var template;
+ template = this.template();
+ $(this.el).html(template(this.model));
+ this.isParam = this.model.isParam;
+ if (this.isParam) {
+ $('label[for=contentType]', $(this.el)).text('Parameter content type:');
+ } else {
+ $('label[for=contentType]', $(this.el)).text('Response Content Type');
+ }
+ return this;
+ };
+
+ ContentTypeView.prototype.template = function() {
+ return Handlebars.templates.content_type;
+ };
+
+ return ContentTypeView;
+
+ })(Backbone.View);
+
}).call(this);