You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

2698 lines
103 KiB

  1. // swagger-ui.js
  2. // version 2.1.0-alpha.7
  3. $(function() {
  4. // Helper function for vertically aligning DOM elements
  5. // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
  6. $.fn.vAlign = function() {
  7. return this.each(function(i){
  8. var ah = $(this).height();
  9. var ph = $(this).parent().height();
  10. var mh = (ph - ah) / 2;
  11. $(this).css('margin-top', mh);
  12. });
  13. };
  14. $.fn.stretchFormtasticInputWidthToParent = function() {
  15. return this.each(function(i){
  16. var p_width = $(this).closest("form").innerWidth();
  17. var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
  18. var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
  19. $(this).css('width', p_width - p_padding - this_padding);
  20. });
  21. };
  22. $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
  23. // Vertically center these paragraphs
  24. // Parent may need a min-height for this to work..
  25. $('ul.downplayed li div.content p').vAlign();
  26. // When a sandbox form is submitted..
  27. $("form.sandbox").submit(function(){
  28. var error_free = true;
  29. // Cycle through the forms required inputs
  30. $(this).find("input.required").each(function() {
  31. // Remove any existing error styles from the input
  32. $(this).removeClass('error');
  33. // Tack the error style on if the input is empty..
  34. if ($(this).val() == '') {
  35. $(this).addClass('error');
  36. $(this).wiggle();
  37. error_free = false;
  38. }
  39. });
  40. return error_free;
  41. });
  42. });
  43. function clippyCopiedCallback(a) {
  44. $('#api_key_copied').fadeIn().delay(1000).fadeOut();
  45. // var b = $("#clippy_tooltip_" + a);
  46. // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
  47. // b.attr("title", "copy to clipboard")
  48. // },
  49. // 500))
  50. }
  51. // Logging function that accounts for browsers that don't have window.console
  52. log = function(){
  53. log.history = log.history || [];
  54. log.history.push(arguments);
  55. if(this.console){
  56. console.log( Array.prototype.slice.call(arguments)[0] );
  57. }
  58. };
  59. // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
  60. if (Function.prototype.bind && console && typeof console.log == "object") {
  61. [
  62. "log","info","warn","error","assert","dir","clear","profile","profileEnd"
  63. ].forEach(function (method) {
  64. console[method] = this.bind(console[method], console);
  65. }, Function.prototype.call);
  66. }
  67. var Docs = {
  68. shebang: function() {
  69. // If shebang has an operation nickname in it..
  70. // e.g. /docs/#!/words/get_search
  71. var fragments = $.param.fragment().split('/');
  72. fragments.shift(); // get rid of the bang
  73. switch (fragments.length) {
  74. case 1:
  75. // Expand all operations for the resource and scroll to it
  76. var dom_id = 'resource_' + fragments[0];
  77. Docs.expandEndpointListForResource(fragments[0]);
  78. $("#"+dom_id).slideto({highlight: false});
  79. break;
  80. case 2:
  81. // Refer to the endpoint DOM element, e.g. #words_get_search
  82. // Expand Resource
  83. Docs.expandEndpointListForResource(fragments[0]);
  84. $("#"+dom_id).slideto({highlight: false});
  85. // Expand operation
  86. var li_dom_id = fragments.join('_');
  87. var li_content_dom_id = li_dom_id + "_content";
  88. Docs.expandOperation($('#'+li_content_dom_id));
  89. $('#'+li_dom_id).slideto({highlight: false});
  90. break;
  91. }
  92. },
  93. toggleEndpointListForResource: function(resource) {
  94. var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
  95. if (elem.is(':visible')) {
  96. Docs.collapseEndpointListForResource(resource);
  97. } else {
  98. Docs.expandEndpointListForResource(resource);
  99. }
  100. },
  101. // Expand resource
  102. expandEndpointListForResource: function(resource) {
  103. var resource = Docs.escapeResourceName(resource);
  104. if (resource == '') {
  105. $('.resource ul.endpoints').slideDown();
  106. return;
  107. }
  108. $('li#resource_' + resource).addClass('active');
  109. var elem = $('li#resource_' + resource + ' ul.endpoints');
  110. elem.slideDown();
  111. },
  112. // Collapse resource and mark as explicitly closed
  113. collapseEndpointListForResource: function(resource) {
  114. var resource = Docs.escapeResourceName(resource);
  115. $('li#resource_' + resource).removeClass('active');
  116. var elem = $('li#resource_' + resource + ' ul.endpoints');
  117. elem.slideUp();
  118. },
  119. expandOperationsForResource: function(resource) {
  120. // Make sure the resource container is open..
  121. Docs.expandEndpointListForResource(resource);
  122. if (resource == '') {
  123. $('.resource ul.endpoints li.operation div.content').slideDown();
  124. return;
  125. }
  126. $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
  127. Docs.expandOperation($(this));
  128. });
  129. },
  130. collapseOperationsForResource: function(resource) {
  131. // Make sure the resource container is open..
  132. Docs.expandEndpointListForResource(resource);
  133. $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
  134. Docs.collapseOperation($(this));
  135. });
  136. },
  137. escapeResourceName: function(resource) {
  138. return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
  139. },
  140. expandOperation: function(elem) {
  141. elem.slideDown();
  142. },
  143. collapseOperation: function(elem) {
  144. elem.slideUp();
  145. }
  146. };(function() {
  147. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  148. templates['apikey_button_view'] = template(function (Handlebars,depth0,helpers,partials,data) {
  149. this.compilerInfo = [4,'>= 1.0.0'];
  150. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  151. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  152. buffer += "<div class='auth_button' id='apikey_button'><img class='auth_icon' alt='apply api key' src='images/apikey.jpeg'></div>\n<div class='auth_container' id='apikey_container'>\n <div class='key_input_container'>\n <div class='auth_label'>";
  153. if (stack1 = helpers.keyName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  154. else { stack1 = depth0.keyName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  155. buffer += escapeExpression(stack1)
  156. + "</div>\n <input placeholder=\"api_key\" class=\"auth_input\" id=\"input_apiKey_entry\" name=\"apiKey\" type=\"text\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_api_key\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
  157. return buffer;
  158. });
  159. })();
  160. (function() {
  161. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  162. templates['basic_auth_button_view'] = template(function (Handlebars,depth0,helpers,partials,data) {
  163. this.compilerInfo = [4,'>= 1.0.0'];
  164. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  165. return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\">Username</div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\">Password</div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
  166. });
  167. })();
  168. (function() {
  169. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  170. templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  171. this.compilerInfo = [4,'>= 1.0.0'];
  172. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  173. var buffer = "", stack1, functionType="function", self=this;
  174. function program1(depth0,data) {
  175. var buffer = "", stack1;
  176. buffer += "\n ";
  177. stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  178. if(stack1 || stack1 === 0) { buffer += stack1; }
  179. buffer += "\n";
  180. return buffer;
  181. }
  182. function program2(depth0,data) {
  183. var buffer = "", stack1;
  184. buffer += "\n <option value=\"";
  185. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  186. if(stack1 || stack1 === 0) { buffer += stack1; }
  187. buffer += "\">";
  188. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  189. if(stack1 || stack1 === 0) { buffer += stack1; }
  190. buffer += "</option>\n ";
  191. return buffer;
  192. }
  193. function program4(depth0,data) {
  194. return "\n <option value=\"application/json\">application/json</option>\n";
  195. }
  196. buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
  197. stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  198. if(stack1 || stack1 === 0) { buffer += stack1; }
  199. buffer += "\n</select>\n";
  200. return buffer;
  201. });
  202. })();
  203. (function() {
  204. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  205. templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) {
  206. this.compilerInfo = [4,'>= 1.0.0'];
  207. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  208. var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this;
  209. function program1(depth0,data) {
  210. var buffer = "", stack1, stack2;
  211. buffer += "\n <div class=\"info_title\">"
  212. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  213. + "</div>\n <div class=\"info_description\">";
  214. stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
  215. if(stack2 || stack2 === 0) { buffer += stack2; }
  216. buffer += "</div>\n ";
  217. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  218. if(stack2 || stack2 === 0) { buffer += stack2; }
  219. buffer += "\n ";
  220. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
  221. if(stack2 || stack2 === 0) { buffer += stack2; }
  222. buffer += "\n ";
  223. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
  224. if(stack2 || stack2 === 0) { buffer += stack2; }
  225. buffer += "\n ";
  226. return buffer;
  227. }
  228. function program2(depth0,data) {
  229. var buffer = "", stack1;
  230. buffer += "<div class=\"info_tos\"><a href=\""
  231. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  232. + "\">Terms of service</a></div>";
  233. return buffer;
  234. }
  235. function program4(depth0,data) {
  236. var buffer = "", stack1;
  237. buffer += "<div class='info_contact'><a href=\"mailto:"
  238. + escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  239. + "\">Contact the developer</a></div>";
  240. return buffer;
  241. }
  242. function program6(depth0,data) {
  243. var buffer = "", stack1;
  244. buffer += "<div class='info_license'><a href='"
  245. + escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),stack1 == null || stack1 === false ? stack1 : stack1.url)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  246. + "'>"
  247. + escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  248. + "</a></div>";
  249. return buffer;
  250. }
  251. function program8(depth0,data) {
  252. var buffer = "", stack1;
  253. buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: "
  254. + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.version)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  255. + "\n ";
  256. return buffer;
  257. }
  258. function program10(depth0,data) {
  259. var buffer = "", stack1;
  260. buffer += "\n <span style=\"float:right\"><a href=\"";
  261. if (stack1 = helpers.validatorUrl) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  262. else { stack1 = depth0.validatorUrl; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  263. buffer += escapeExpression(stack1)
  264. + "/debug?url=";
  265. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  266. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  267. buffer += escapeExpression(stack1)
  268. + "\"><img id=\"validator\" src=\"";
  269. if (stack1 = helpers.validatorUrl) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  270. else { stack1 = depth0.validatorUrl; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  271. buffer += escapeExpression(stack1)
  272. + "?url=";
  273. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  274. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  275. buffer += escapeExpression(stack1)
  276. + "\"></a>\n </span>\n ";
  277. return buffer;
  278. }
  279. buffer += "<div class='info' id='api_info'>\n ";
  280. stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
  281. if(stack1 || stack1 === 0) { buffer += stack1; }
  282. buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
  283. if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  284. else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  285. buffer += escapeExpression(stack1)
  286. + "\n ";
  287. stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.version), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
  288. if(stack2 || stack2 === 0) { buffer += stack2; }
  289. buffer += "]\n ";
  290. stack2 = helpers['if'].call(depth0, depth0.validatorUrl, {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
  291. if(stack2 || stack2 === 0) { buffer += stack2; }
  292. buffer += "\n </h4>\n </div>\n</div>\n";
  293. return buffer;
  294. });
  295. })();
  296. (function() {
  297. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  298. templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) {
  299. this.compilerInfo = [4,'>= 1.0.0'];
  300. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  301. var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
  302. function program1(depth0,data) {
  303. return "deprecated";
  304. }
  305. function program3(depth0,data) {
  306. return "\n <h4>Warning: Deprecated</h4>\n ";
  307. }
  308. function program5(depth0,data) {
  309. var buffer = "", stack1;
  310. buffer += "\n <h4>Implementation Notes</h4>\n <p>";
  311. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  312. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  313. if(stack1 || stack1 === 0) { buffer += stack1; }
  314. buffer += "</p>\n ";
  315. return buffer;
  316. }
  317. function program7(depth0,data) {
  318. return "\n <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
  319. }
  320. function program9(depth0,data) {
  321. var buffer = "", stack1;
  322. buffer += "\n <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n ";
  323. stack1 = helpers.each.call(depth0, depth0, {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
  324. if(stack1 || stack1 === 0) { buffer += stack1; }
  325. buffer += "\n </div>\n ";
  326. return buffer;
  327. }
  328. function program10(depth0,data) {
  329. var buffer = "", stack1, stack2;
  330. buffer += "\n <div title='";
  331. stack2 = ((stack1 = depth0.description),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
  332. if(stack2 || stack2 === 0) { buffer += stack2; }
  333. buffer += "'>"
  334. + escapeExpression(((stack1 = depth0.scope),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
  335. + "</div>\n ";
  336. return buffer;
  337. }
  338. function program12(depth0,data) {
  339. return "</div>";
  340. }
  341. function program14(depth0,data) {
  342. return "\n <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n ";
  343. }
  344. function program16(depth0,data) {
  345. return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
  346. }
  347. function program18(depth0,data) {
  348. 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: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
  349. }
  350. function program20(depth0,data) {
  351. return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
  352. }
  353. function program22(depth0,data) {
  354. return "\n ";
  355. }
  356. function program24(depth0,data) {
  357. 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 <span class='response_throbber' style='display:none'></span>\n </div>\n ";
  358. }
  359. buffer += "\n <ul class='operations' >\n <li class='";
  360. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  361. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  362. buffer += escapeExpression(stack1)
  363. + " operation' id='";
  364. if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  365. else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  366. buffer += escapeExpression(stack1)
  367. + "_";
  368. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  369. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  370. buffer += escapeExpression(stack1)
  371. + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";
  372. if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  373. else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  374. buffer += escapeExpression(stack1)
  375. + "/";
  376. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  377. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  378. buffer += escapeExpression(stack1)
  379. + "' class=\"toggleOperation\">";
  380. if (stack1 = helpers.method) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  381. else { stack1 = depth0.method; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  382. buffer += escapeExpression(stack1)
  383. + "</a>\n </span>\n <span class='path'>\n <a href='#!/";
  384. if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  385. else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  386. buffer += escapeExpression(stack1)
  387. + "/";
  388. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  389. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  390. buffer += escapeExpression(stack1)
  391. + "' class=\"toggleOperation ";
  392. stack1 = helpers['if'].call(depth0, depth0.deprecated, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
  393. if(stack1 || stack1 === 0) { buffer += stack1; }
  394. buffer += "\">";
  395. if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  396. else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  397. buffer += escapeExpression(stack1)
  398. + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";
  399. if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  400. else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  401. buffer += escapeExpression(stack1)
  402. + "/";
  403. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  404. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  405. buffer += escapeExpression(stack1)
  406. + "' class=\"toggleOperation\">";
  407. if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  408. else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  409. if(stack1 || stack1 === 0) { buffer += stack1; }
  410. buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";
  411. if (stack1 = helpers.parentId) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  412. else { stack1 = depth0.parentId; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  413. buffer += escapeExpression(stack1)
  414. + "_";
  415. if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  416. else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  417. buffer += escapeExpression(stack1)
  418. + "_content' style='display:none'>\n ";
  419. stack1 = helpers['if'].call(depth0, depth0.deprecated, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
  420. if(stack1 || stack1 === 0) { buffer += stack1; }
  421. buffer += "\n ";
  422. stack1 = helpers['if'].call(depth0, depth0.description, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
  423. if(stack1 || stack1 === 0) { buffer += stack1; }
  424. buffer += "\n ";
  425. options = {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data};
  426. if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
  427. else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  428. if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  429. if(stack1 || stack1 === 0) { buffer += stack1; }
  430. buffer += "\n ";
  431. stack1 = helpers.each.call(depth0, depth0.oauth, {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
  432. if(stack1 || stack1 === 0) { buffer += stack1; }
  433. buffer += "\n ";
  434. options = {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data};
  435. if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
  436. else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  437. if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  438. if(stack1 || stack1 === 0) { buffer += stack1; }
  439. buffer += "\n ";
  440. options = {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data};
  441. if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
  442. else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  443. if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  444. if(stack1 || stack1 === 0) { buffer += stack1; }
  445. buffer += "\n ";
  446. stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
  447. if(stack1 || stack1 === 0) { buffer += stack1; }
  448. buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
  449. stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(18, program18, data),data:data});
  450. if(stack1 || stack1 === 0) { buffer += stack1; }
  451. buffer += "\n ";
  452. stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(20, program20, data),data:data});
  453. if(stack1 || stack1 === 0) { buffer += stack1; }
  454. buffer += "\n ";
  455. stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(24, program24, data),fn:self.program(22, program22, data),data:data});
  456. if(stack1 || stack1 === 0) { buffer += stack1; }
  457. 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";
  458. return buffer;
  459. });
  460. })();
  461. (function() {
  462. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  463. templates['param'] = template(function (Handlebars,depth0,helpers,partials,data) {
  464. this.compilerInfo = [4,'>= 1.0.0'];
  465. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  466. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  467. function program1(depth0,data) {
  468. var buffer = "", stack1;
  469. buffer += "\n ";
  470. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
  471. if(stack1 || stack1 === 0) { buffer += stack1; }
  472. buffer += "\n ";
  473. return buffer;
  474. }
  475. function program2(depth0,data) {
  476. var buffer = "", stack1;
  477. buffer += "\n <input type=\"file\" name='";
  478. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  479. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  480. buffer += escapeExpression(stack1)
  481. + "'/>\n <div class=\"parameter-content-type\" />\n ";
  482. return buffer;
  483. }
  484. function program4(depth0,data) {
  485. var buffer = "", stack1;
  486. buffer += "\n ";
  487. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
  488. if(stack1 || stack1 === 0) { buffer += stack1; }
  489. buffer += "\n ";
  490. return buffer;
  491. }
  492. function program5(depth0,data) {
  493. var buffer = "", stack1;
  494. buffer += "\n <textarea class='body-textarea' name='";
  495. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  496. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  497. buffer += escapeExpression(stack1)
  498. + "'>";
  499. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  500. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  501. buffer += escapeExpression(stack1)
  502. + "</textarea>\n ";
  503. return buffer;
  504. }
  505. function program7(depth0,data) {
  506. var buffer = "", stack1;
  507. buffer += "\n <textarea class='body-textarea' name='";
  508. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  509. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  510. buffer += escapeExpression(stack1)
  511. + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
  512. return buffer;
  513. }
  514. function program9(depth0,data) {
  515. var buffer = "", stack1;
  516. buffer += "\n ";
  517. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(10, program10, data),fn:self.program(2, program2, data),data:data});
  518. if(stack1 || stack1 === 0) { buffer += stack1; }
  519. buffer += "\n ";
  520. return buffer;
  521. }
  522. function program10(depth0,data) {
  523. var buffer = "", stack1;
  524. buffer += "\n ";
  525. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data});
  526. if(stack1 || stack1 === 0) { buffer += stack1; }
  527. buffer += "\n ";
  528. return buffer;
  529. }
  530. function program11(depth0,data) {
  531. var buffer = "", stack1;
  532. buffer += "\n <input class='parameter' minlength='0' name='";
  533. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  534. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  535. buffer += escapeExpression(stack1)
  536. + "' placeholder='' type='text' value='";
  537. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  538. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  539. buffer += escapeExpression(stack1)
  540. + "'/>\n ";
  541. return buffer;
  542. }
  543. function program13(depth0,data) {
  544. var buffer = "", stack1;
  545. buffer += "\n <input class='parameter' minlength='0' name='";
  546. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  547. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  548. buffer += escapeExpression(stack1)
  549. + "' placeholder='' type='text' value=''/>\n ";
  550. return buffer;
  551. }
  552. buffer += "<td class='code'>";
  553. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  554. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  555. buffer += escapeExpression(stack1)
  556. + "</td>\n<td>\n\n ";
  557. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
  558. if(stack1 || stack1 === 0) { buffer += stack1; }
  559. buffer += "\n\n</td>\n<td>";
  560. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  561. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  562. if(stack1 || stack1 === 0) { buffer += stack1; }
  563. buffer += "</td>\n<td>";
  564. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  565. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  566. if(stack1 || stack1 === 0) { buffer += stack1; }
  567. buffer += "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
  568. return buffer;
  569. });
  570. })();
  571. (function() {
  572. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  573. templates['param_list'] = template(function (Handlebars,depth0,helpers,partials,data) {
  574. this.compilerInfo = [4,'>= 1.0.0'];
  575. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  576. var buffer = "", stack1, stack2, options, self=this, helperMissing=helpers.helperMissing, functionType="function", escapeExpression=this.escapeExpression;
  577. function program1(depth0,data) {
  578. return " multiple='multiple'";
  579. }
  580. function program3(depth0,data) {
  581. return "\n ";
  582. }
  583. function program5(depth0,data) {
  584. var buffer = "", stack1;
  585. buffer += "\n ";
  586. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data});
  587. if(stack1 || stack1 === 0) { buffer += stack1; }
  588. buffer += "\n ";
  589. return buffer;
  590. }
  591. function program6(depth0,data) {
  592. return "\n ";
  593. }
  594. function program8(depth0,data) {
  595. var buffer = "", stack1, stack2, options;
  596. buffer += "\n ";
  597. options = {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data};
  598. stack2 = ((stack1 = helpers.isArray || depth0.isArray),stack1 ? stack1.call(depth0, depth0, options) : helperMissing.call(depth0, "isArray", depth0, options));
  599. if(stack2 || stack2 === 0) { buffer += stack2; }
  600. buffer += "\n ";
  601. return buffer;
  602. }
  603. function program9(depth0,data) {
  604. return "\n ";
  605. }
  606. function program11(depth0,data) {
  607. return "\n <option selected=\"\" value=''></option>\n ";
  608. }
  609. function program13(depth0,data) {
  610. var buffer = "", stack1;
  611. buffer += "\n ";
  612. stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data});
  613. if(stack1 || stack1 === 0) { buffer += stack1; }
  614. buffer += "\n ";
  615. return buffer;
  616. }
  617. function program14(depth0,data) {
  618. var buffer = "", stack1;
  619. buffer += "\n <option selected=\"\" value='";
  620. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  621. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  622. buffer += escapeExpression(stack1)
  623. + "'>";
  624. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  625. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  626. buffer += escapeExpression(stack1)
  627. + " (default)</option>\n ";
  628. return buffer;
  629. }
  630. function program16(depth0,data) {
  631. var buffer = "", stack1;
  632. buffer += "\n <option value='";
  633. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  634. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  635. buffer += escapeExpression(stack1)
  636. + "'>";
  637. if (stack1 = helpers.value) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  638. else { stack1 = depth0.value; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  639. buffer += escapeExpression(stack1)
  640. + "</option>\n ";
  641. return buffer;
  642. }
  643. buffer += "<td class='code'>";
  644. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  645. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  646. buffer += escapeExpression(stack1)
  647. + "</td>\n<td>\n <select ";
  648. options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
  649. stack2 = ((stack1 = helpers.isArray || depth0.isArray),stack1 ? stack1.call(depth0, depth0, options) : helperMissing.call(depth0, "isArray", depth0, options));
  650. if(stack2 || stack2 === 0) { buffer += stack2; }
  651. buffer += " class='parameter' name='";
  652. if (stack2 = helpers.name) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  653. else { stack2 = depth0.name; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  654. buffer += escapeExpression(stack2)
  655. + "'>\n ";
  656. stack2 = helpers['if'].call(depth0, depth0.required, {hash:{},inverse:self.program(5, program5, data),fn:self.program(3, program3, data),data:data});
  657. if(stack2 || stack2 === 0) { buffer += stack2; }
  658. buffer += "\n ";
  659. stack2 = helpers.each.call(depth0, ((stack1 = depth0.allowableValues),stack1 == null || stack1 === false ? stack1 : stack1.descriptiveValues), {hash:{},inverse:self.noop,fn:self.program(13, program13, data),data:data});
  660. if(stack2 || stack2 === 0) { buffer += stack2; }
  661. buffer += "\n </select>\n</td>\n<td>";
  662. if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  663. else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  664. if(stack2 || stack2 === 0) { buffer += stack2; }
  665. buffer += "</td>\n<td>";
  666. if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); }
  667. else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; }
  668. if(stack2 || stack2 === 0) { buffer += stack2; }
  669. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>";
  670. return buffer;
  671. });
  672. })();
  673. (function() {
  674. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  675. templates['param_readonly'] = template(function (Handlebars,depth0,helpers,partials,data) {
  676. this.compilerInfo = [4,'>= 1.0.0'];
  677. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  678. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  679. function program1(depth0,data) {
  680. var buffer = "", stack1;
  681. buffer += "\n <textarea class='body-textarea' readonly='readonly' name='";
  682. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  683. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  684. buffer += escapeExpression(stack1)
  685. + "'>";
  686. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  687. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  688. buffer += escapeExpression(stack1)
  689. + "</textarea>\n ";
  690. return buffer;
  691. }
  692. function program3(depth0,data) {
  693. var buffer = "", stack1;
  694. buffer += "\n ";
  695. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  696. if(stack1 || stack1 === 0) { buffer += stack1; }
  697. buffer += "\n ";
  698. return buffer;
  699. }
  700. function program4(depth0,data) {
  701. var buffer = "", stack1;
  702. buffer += "\n ";
  703. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  704. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  705. buffer += escapeExpression(stack1)
  706. + "\n ";
  707. return buffer;
  708. }
  709. function program6(depth0,data) {
  710. return "\n (empty)\n ";
  711. }
  712. buffer += "<td class='code'>";
  713. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  714. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  715. buffer += escapeExpression(stack1)
  716. + "</td>\n<td>\n ";
  717. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  718. if(stack1 || stack1 === 0) { buffer += stack1; }
  719. buffer += "\n</td>\n<td>";
  720. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  721. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  722. if(stack1 || stack1 === 0) { buffer += stack1; }
  723. buffer += "</td>\n<td>";
  724. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  725. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  726. if(stack1 || stack1 === 0) { buffer += stack1; }
  727. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  728. return buffer;
  729. });
  730. })();
  731. (function() {
  732. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  733. templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  734. this.compilerInfo = [4,'>= 1.0.0'];
  735. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  736. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  737. function program1(depth0,data) {
  738. var buffer = "", stack1;
  739. buffer += "\n <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";
  740. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  741. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  742. buffer += escapeExpression(stack1)
  743. + "'>";
  744. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  745. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  746. buffer += escapeExpression(stack1)
  747. + "</textarea>\n ";
  748. return buffer;
  749. }
  750. function program3(depth0,data) {
  751. var buffer = "", stack1;
  752. buffer += "\n ";
  753. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data});
  754. if(stack1 || stack1 === 0) { buffer += stack1; }
  755. buffer += "\n ";
  756. return buffer;
  757. }
  758. function program4(depth0,data) {
  759. var buffer = "", stack1;
  760. buffer += "\n ";
  761. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  762. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  763. buffer += escapeExpression(stack1)
  764. + "\n ";
  765. return buffer;
  766. }
  767. function program6(depth0,data) {
  768. return "\n (empty)\n ";
  769. }
  770. buffer += "<td class='code required'>";
  771. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  772. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  773. buffer += escapeExpression(stack1)
  774. + "</td>\n<td>\n ";
  775. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data});
  776. if(stack1 || stack1 === 0) { buffer += stack1; }
  777. buffer += "\n</td>\n<td>";
  778. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  779. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  780. if(stack1 || stack1 === 0) { buffer += stack1; }
  781. buffer += "</td>\n<td>";
  782. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  783. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  784. if(stack1 || stack1 === 0) { buffer += stack1; }
  785. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  786. return buffer;
  787. });
  788. })();
  789. (function() {
  790. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  791. templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) {
  792. this.compilerInfo = [4,'>= 1.0.0'];
  793. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  794. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
  795. function program1(depth0,data) {
  796. var buffer = "", stack1;
  797. buffer += "\n ";
  798. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data});
  799. if(stack1 || stack1 === 0) { buffer += stack1; }
  800. buffer += "\n ";
  801. return buffer;
  802. }
  803. function program2(depth0,data) {
  804. var buffer = "", stack1;
  805. buffer += "\n <input type=\"file\" name='";
  806. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  807. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  808. buffer += escapeExpression(stack1)
  809. + "'/>\n ";
  810. return buffer;
  811. }
  812. function program4(depth0,data) {
  813. var buffer = "", stack1;
  814. buffer += "\n ";
  815. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
  816. if(stack1 || stack1 === 0) { buffer += stack1; }
  817. buffer += "\n ";
  818. return buffer;
  819. }
  820. function program5(depth0,data) {
  821. var buffer = "", stack1;
  822. buffer += "\n <textarea class='body-textarea required' placeholder='(required)' name='";
  823. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  824. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  825. buffer += escapeExpression(stack1)
  826. + "'>";
  827. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  828. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  829. buffer += escapeExpression(stack1)
  830. + "</textarea>\n ";
  831. return buffer;
  832. }
  833. function program7(depth0,data) {
  834. var buffer = "", stack1;
  835. buffer += "\n <textarea class='body-textarea required' placeholder='(required)' name='";
  836. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  837. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  838. buffer += escapeExpression(stack1)
  839. + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n ";
  840. return buffer;
  841. }
  842. function program9(depth0,data) {
  843. var buffer = "", stack1;
  844. buffer += "\n ";
  845. stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data});
  846. if(stack1 || stack1 === 0) { buffer += stack1; }
  847. buffer += "\n ";
  848. return buffer;
  849. }
  850. function program10(depth0,data) {
  851. var buffer = "", stack1;
  852. buffer += "\n <input class='parameter' class='required' type='file' name='";
  853. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  854. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  855. buffer += escapeExpression(stack1)
  856. + "'/>\n ";
  857. return buffer;
  858. }
  859. function program12(depth0,data) {
  860. var buffer = "", stack1;
  861. buffer += "\n ";
  862. stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(15, program15, data),fn:self.program(13, program13, data),data:data});
  863. if(stack1 || stack1 === 0) { buffer += stack1; }
  864. buffer += "\n ";
  865. return buffer;
  866. }
  867. function program13(depth0,data) {
  868. var buffer = "", stack1;
  869. buffer += "\n <input class='parameter required' minlength='1' name='";
  870. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  871. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  872. buffer += escapeExpression(stack1)
  873. + "' placeholder='(required)' type='text' value='";
  874. if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  875. else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  876. buffer += escapeExpression(stack1)
  877. + "'/>\n ";
  878. return buffer;
  879. }
  880. function program15(depth0,data) {
  881. var buffer = "", stack1;
  882. buffer += "\n <input class='parameter required' minlength='1' name='";
  883. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  884. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  885. buffer += escapeExpression(stack1)
  886. + "' placeholder='(required)' type='text' value=''/>\n ";
  887. return buffer;
  888. }
  889. buffer += "<td class='code required'>";
  890. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  891. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  892. buffer += escapeExpression(stack1)
  893. + "</td>\n<td>\n ";
  894. stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data});
  895. if(stack1 || stack1 === 0) { buffer += stack1; }
  896. buffer += "\n</td>\n<td>\n <strong>";
  897. if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  898. else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  899. if(stack1 || stack1 === 0) { buffer += stack1; }
  900. buffer += "</strong>\n</td>\n<td>";
  901. if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  902. else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  903. if(stack1 || stack1 === 0) { buffer += stack1; }
  904. buffer += "</td>\n<td><span class=\"model-signature\"></span></td>\n";
  905. return buffer;
  906. });
  907. })();
  908. (function() {
  909. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  910. templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  911. this.compilerInfo = [4,'>= 1.0.0'];
  912. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  913. var buffer = "", stack1, functionType="function", self=this;
  914. function program1(depth0,data) {
  915. var buffer = "", stack1;
  916. buffer += "\n ";
  917. stack1 = helpers.each.call(depth0, depth0.consumes, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  918. if(stack1 || stack1 === 0) { buffer += stack1; }
  919. buffer += "\n";
  920. return buffer;
  921. }
  922. function program2(depth0,data) {
  923. var buffer = "", stack1;
  924. buffer += "\n <option value=\"";
  925. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  926. if(stack1 || stack1 === 0) { buffer += stack1; }
  927. buffer += "\">";
  928. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  929. if(stack1 || stack1 === 0) { buffer += stack1; }
  930. buffer += "</option>\n ";
  931. return buffer;
  932. }
  933. function program4(depth0,data) {
  934. return "\n <option value=\"application/json\">application/json</option>\n";
  935. }
  936. buffer += "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
  937. stack1 = helpers['if'].call(depth0, depth0.consumes, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  938. if(stack1 || stack1 === 0) { buffer += stack1; }
  939. buffer += "\n</select>\n";
  940. return buffer;
  941. });
  942. })();
  943. (function() {
  944. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  945. templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) {
  946. this.compilerInfo = [4,'>= 1.0.0'];
  947. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  948. var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing;
  949. function program1(depth0,data) {
  950. return " : ";
  951. }
  952. function program3(depth0,data) {
  953. var buffer = "", stack1;
  954. buffer += "<li>\n <a href='";
  955. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  956. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  957. buffer += escapeExpression(stack1)
  958. + "'>Raw</a>\n </li>";
  959. return buffer;
  960. }
  961. buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
  962. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  963. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  964. buffer += escapeExpression(stack1)
  965. + "' class=\"toggleEndpointList\" data-id=\"";
  966. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  967. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  968. buffer += escapeExpression(stack1)
  969. + "\">";
  970. if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  971. else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  972. buffer += escapeExpression(stack1)
  973. + "</a> ";
  974. options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
  975. if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, options); }
  976. else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  977. if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  978. if(stack1 || stack1 === 0) { buffer += stack1; }
  979. if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  980. else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  981. if(stack1 || stack1 === 0) { buffer += stack1; }
  982. buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
  983. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  984. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  985. buffer += escapeExpression(stack1)
  986. + "' id='endpointListTogger_";
  987. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  988. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  989. buffer += escapeExpression(stack1)
  990. + "' class=\"toggleEndpointList\" data-id=\"";
  991. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  992. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  993. buffer += escapeExpression(stack1)
  994. + "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\"";
  995. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  996. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  997. buffer += escapeExpression(stack1)
  998. + "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=";
  999. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1000. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1001. buffer += escapeExpression(stack1)
  1002. + ">\n Expand Operations\n </a>\n </li>\n ";
  1003. options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data};
  1004. if (stack1 = helpers.url) { stack1 = stack1.call(depth0, options); }
  1005. else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1006. if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
  1007. if(stack1 || stack1 === 0) { buffer += stack1; }
  1008. buffer += "\n </ul>\n</div>\n<ul class='endpoints' id='";
  1009. if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1010. else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1011. buffer += escapeExpression(stack1)
  1012. + "_endpoint_list' style='display:none'>\n\n</ul>\n";
  1013. return buffer;
  1014. });
  1015. })();
  1016. (function() {
  1017. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  1018. templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
  1019. this.compilerInfo = [4,'>= 1.0.0'];
  1020. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  1021. var buffer = "", stack1, functionType="function", self=this;
  1022. function program1(depth0,data) {
  1023. var buffer = "", stack1;
  1024. buffer += "\n ";
  1025. stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
  1026. if(stack1 || stack1 === 0) { buffer += stack1; }
  1027. buffer += "\n";
  1028. return buffer;
  1029. }
  1030. function program2(depth0,data) {
  1031. var buffer = "", stack1;
  1032. buffer += "\n <option value=\"";
  1033. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  1034. if(stack1 || stack1 === 0) { buffer += stack1; }
  1035. buffer += "\">";
  1036. stack1 = (typeof depth0 === functionType ? depth0.apply(depth0) : depth0);
  1037. if(stack1 || stack1 === 0) { buffer += stack1; }
  1038. buffer += "</option>\n ";
  1039. return buffer;
  1040. }
  1041. function program4(depth0,data) {
  1042. return "\n <option value=\"application/json\">application/json</option>\n";
  1043. }
  1044. buffer += "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
  1045. stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data});
  1046. if(stack1 || stack1 === 0) { buffer += stack1; }
  1047. buffer += "\n</select>\n";
  1048. return buffer;
  1049. });
  1050. })();
  1051. (function() {
  1052. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  1053. templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) {
  1054. this.compilerInfo = [4,'>= 1.0.0'];
  1055. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  1056. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  1057. 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 ";
  1058. if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1059. else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1060. if(stack1 || stack1 === 0) { buffer += stack1; }
  1061. buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
  1062. if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1063. else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1064. buffer += escapeExpression(stack1)
  1065. + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
  1066. return buffer;
  1067. });
  1068. })();
  1069. (function() {
  1070. var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
  1071. templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) {
  1072. this.compilerInfo = [4,'>= 1.0.0'];
  1073. helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
  1074. var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
  1075. buffer += "<td width='15%' class='code'>";
  1076. if (stack1 = helpers.code) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1077. else { stack1 = depth0.code; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1078. buffer += escapeExpression(stack1)
  1079. + "</td>\n<td>";
  1080. if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
  1081. else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
  1082. if(stack1 || stack1 === 0) { buffer += stack1; }
  1083. buffer += "</td>\n<td width='50%'><span class=\"model-signature\" /></td>";
  1084. return buffer;
  1085. });
  1086. })();
  1087. // Generated by CoffeeScript 1.6.3
  1088. (function() {
  1089. var ApiKeyButton, BasicAuthButton, ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref11, _ref12, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
  1090. __hasProp = {}.hasOwnProperty,
  1091. __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; };
  1092. SwaggerUi = (function(_super) {
  1093. __extends(SwaggerUi, _super);
  1094. function SwaggerUi() {
  1095. _ref = SwaggerUi.__super__.constructor.apply(this, arguments);
  1096. return _ref;
  1097. }
  1098. SwaggerUi.prototype.dom_id = "swagger_ui";
  1099. SwaggerUi.prototype.options = null;
  1100. SwaggerUi.prototype.api = null;
  1101. SwaggerUi.prototype.headerView = null;
  1102. SwaggerUi.prototype.mainView = null;
  1103. SwaggerUi.prototype.initialize = function(options) {
  1104. var _this = this;
  1105. if (options == null) {
  1106. options = {};
  1107. }
  1108. if (options.dom_id != null) {
  1109. this.dom_id = options.dom_id;
  1110. delete options.dom_id;
  1111. }
  1112. if ($('#' + this.dom_id) == null) {
  1113. $('body').append('<div id="' + this.dom_id + '"></div>');
  1114. }
  1115. this.options = options;
  1116. this.options.success = function() {
  1117. return _this.render();
  1118. };
  1119. this.options.progress = function(d) {
  1120. return _this.showMessage(d);
  1121. };
  1122. this.options.failure = function(d) {
  1123. if (_this.api && _this.api.isValid === false) {
  1124. log("not a valid 2.0 spec, loading legacy client");
  1125. _this.api = new SwaggerApi(_this.options);
  1126. return _this.api.build();
  1127. } else {
  1128. return _this.onLoadFailure(d);
  1129. }
  1130. };
  1131. this.headerView = new HeaderView({
  1132. el: $('#header')
  1133. });
  1134. return this.headerView.on('update-swagger-ui', function(data) {
  1135. return _this.updateSwaggerUi(data);
  1136. });
  1137. };
  1138. SwaggerUi.prototype.setOption = function(option, value) {
  1139. return this.options[option] = value;
  1140. };
  1141. SwaggerUi.prototype.getOption = function(option) {
  1142. return this.options[option];
  1143. };
  1144. SwaggerUi.prototype.updateSwaggerUi = function(data) {
  1145. this.options.url = data.url;
  1146. return this.load();
  1147. };
  1148. SwaggerUi.prototype.load = function() {
  1149. var url, _ref1;
  1150. if ((_ref1 = this.mainView) != null) {
  1151. _ref1.clear();
  1152. }
  1153. url = this.options.url;
  1154. if (url.indexOf("http") !== 0) {
  1155. url = this.buildUrl(window.location.href.toString(), url);
  1156. }
  1157. this.options.url = url;
  1158. this.headerView.update(url);
  1159. this.api = new SwaggerClient(this.options);
  1160. return this.api.build();
  1161. };
  1162. SwaggerUi.prototype.collapseAll = function() {
  1163. return Docs.collapseEndpointListForResource('');
  1164. };
  1165. SwaggerUi.prototype.listAll = function() {
  1166. return Docs.collapseOperationsForResource('');
  1167. };
  1168. SwaggerUi.prototype.expandAll = function() {
  1169. return Docs.expandOperationsForResource('');
  1170. };
  1171. SwaggerUi.prototype.render = function() {
  1172. var _this = this;
  1173. this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
  1174. this.mainView = new MainView({
  1175. model: this.api,
  1176. el: $('#' + this.dom_id),
  1177. swaggerOptions: this.options
  1178. }).render();
  1179. this.showMessage();
  1180. switch (this.options.docExpansion) {
  1181. case "full":
  1182. this.expandAll();
  1183. break;
  1184. case "list":
  1185. this.listAll();
  1186. }
  1187. if (this.options.onComplete) {
  1188. this.options.onComplete(this.api, this);
  1189. }
  1190. return setTimeout(function() {
  1191. return Docs.shebang();
  1192. }, 400);
  1193. };
  1194. SwaggerUi.prototype.buildUrl = function(base, url) {
  1195. var endOfPath, parts;
  1196. log("base is " + base);
  1197. if (url.indexOf("/") === 0) {
  1198. parts = base.split("/");
  1199. base = parts[0] + "//" + parts[2];
  1200. return base + url;
  1201. } else {
  1202. endOfPath = base.length;
  1203. if (base.indexOf("?") > -1) {
  1204. endOfPath = Math.min(endOfPath, base.indexOf("?"));
  1205. }
  1206. if (base.indexOf("#") > -1) {
  1207. endOfPath = Math.min(endOfPath, base.indexOf("#"));
  1208. }
  1209. base = base.substring(0, endOfPath);
  1210. if (base.indexOf("/", base.length - 1) !== -1) {
  1211. return base + url;
  1212. }
  1213. return base + "/" + url;
  1214. }
  1215. };
  1216. SwaggerUi.prototype.showMessage = function(data) {
  1217. if (data == null) {
  1218. data = '';
  1219. }
  1220. $('#message-bar').removeClass('message-fail');
  1221. $('#message-bar').addClass('message-success');
  1222. return $('#message-bar').html(data);
  1223. };
  1224. SwaggerUi.prototype.onLoadFailure = function(data) {
  1225. var val;
  1226. if (data == null) {
  1227. data = '';
  1228. }
  1229. $('#message-bar').removeClass('message-success');
  1230. $('#message-bar').addClass('message-fail');
  1231. val = $('#message-bar').html(data);
  1232. if (this.options.onFailure != null) {
  1233. this.options.onFailure(data);
  1234. }
  1235. return val;
  1236. };
  1237. return SwaggerUi;
  1238. })(Backbone.Router);
  1239. window.SwaggerUi = SwaggerUi;
  1240. HeaderView = (function(_super) {
  1241. __extends(HeaderView, _super);
  1242. function HeaderView() {
  1243. _ref1 = HeaderView.__super__.constructor.apply(this, arguments);
  1244. return _ref1;
  1245. }
  1246. HeaderView.prototype.events = {
  1247. 'click #show-pet-store-icon': 'showPetStore',
  1248. 'click #show-wordnik-dev-icon': 'showWordnikDev',
  1249. 'click #explore': 'showCustom',
  1250. 'keyup #input_baseUrl': 'showCustomOnKeyup',
  1251. 'keyup #input_apiKey': 'showCustomOnKeyup'
  1252. };
  1253. HeaderView.prototype.initialize = function() {};
  1254. HeaderView.prototype.showPetStore = function(e) {
  1255. return this.trigger('update-swagger-ui', {
  1256. url: "http://petstore.swagger.wordnik.com/api/api-docs"
  1257. });
  1258. };
  1259. HeaderView.prototype.showWordnikDev = function(e) {
  1260. return this.trigger('update-swagger-ui', {
  1261. url: "http://api.wordnik.com/v4/resources.json"
  1262. });
  1263. };
  1264. HeaderView.prototype.showCustomOnKeyup = function(e) {
  1265. if (e.keyCode === 13) {
  1266. return this.showCustom();
  1267. }
  1268. };
  1269. HeaderView.prototype.showCustom = function(e) {
  1270. if (e != null) {
  1271. e.preventDefault();
  1272. }
  1273. return this.trigger('update-swagger-ui', {
  1274. url: $('#input_baseUrl').val(),
  1275. apiKey: $('#input_apiKey').val()
  1276. });
  1277. };
  1278. HeaderView.prototype.update = function(url, apiKey, trigger) {
  1279. if (trigger == null) {
  1280. trigger = false;
  1281. }
  1282. $('#input_baseUrl').val(url);
  1283. if (trigger) {
  1284. return this.trigger('update-swagger-ui', {
  1285. url: url
  1286. });
  1287. }
  1288. };
  1289. return HeaderView;
  1290. })(Backbone.View);
  1291. MainView = (function(_super) {
  1292. var sorters;
  1293. __extends(MainView, _super);
  1294. function MainView() {
  1295. _ref2 = MainView.__super__.constructor.apply(this, arguments);
  1296. return _ref2;
  1297. }
  1298. sorters = {
  1299. 'alpha': function(a, b) {
  1300. return a.path.localeCompare(b.path);
  1301. },
  1302. 'method': function(a, b) {
  1303. return a.method.localeCompare(b.method);
  1304. }
  1305. };
  1306. MainView.prototype.initialize = function(opts) {
  1307. var auth, key, name, url, value, _ref3;
  1308. if (opts == null) {
  1309. opts = {};
  1310. }
  1311. this.model.auths = [];
  1312. _ref3 = this.model.securityDefinitions;
  1313. for (key in _ref3) {
  1314. value = _ref3[key];
  1315. auth = {
  1316. name: key,
  1317. type: value.type,
  1318. value: value
  1319. };
  1320. this.model.auths.push(auth);
  1321. }
  1322. if (this.model.info && this.model.info.license && typeof this.model.info.license === 'string') {
  1323. name = this.model.info.license;
  1324. url = this.model.info.licenseUrl;
  1325. this.model.info.license = {};
  1326. this.model.info.license.name = name;
  1327. this.model.info.license.url = url;
  1328. }
  1329. if (!this.model.info) {
  1330. this.model.info = {};
  1331. }
  1332. if (!this.model.info.version) {
  1333. this.model.info.version = this.model.apiVersion;
  1334. }
  1335. if (this.model.swaggerVersion === "2.0") {
  1336. if ("validatorUrl" in opts.swaggerOptions) {
  1337. return this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
  1338. } else if (this.model.url.indexOf("localhost") > 0) {
  1339. return this.model.validatorUrl = null;
  1340. } else {
  1341. return this.model.validatorUrl = "http://online.swagger.io/validator";
  1342. }
  1343. }
  1344. };
  1345. MainView.prototype.render = function() {
  1346. var auth, button, counter, id, name, resource, resources, _i, _len, _ref3;
  1347. if (this.model.securityDefinitions) {
  1348. for (name in this.model.securityDefinitions) {
  1349. auth = this.model.securityDefinitions[name];
  1350. if (auth.type === "apiKey" && $("#apikey_button").length === 0) {
  1351. button = new ApiKeyButton({
  1352. model: auth
  1353. }).render().el;
  1354. $('.auth_main_container').append(button);
  1355. }
  1356. if (auth.type === "basicAuth" && $("#basic_auth_button").length === 0) {
  1357. button = new BasicAuthButton({
  1358. model: auth
  1359. }).render().el;
  1360. $('.auth_main_container').append(button);
  1361. }
  1362. }
  1363. }
  1364. $(this.el).html(Handlebars.templates.main(this.model));
  1365. resources = {};
  1366. counter = 0;
  1367. _ref3 = this.model.apisArray;
  1368. for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
  1369. resource = _ref3[_i];
  1370. id = resource.name;
  1371. while (typeof resources[id] !== 'undefined') {
  1372. id = id + "_" + counter;
  1373. counter += 1;
  1374. }
  1375. resource.id = id;
  1376. resources[id] = resource;
  1377. this.addResource(resource, this.model.auths);
  1378. }
  1379. return this;
  1380. };
  1381. MainView.prototype.addResource = function(resource, auths) {
  1382. var resourceView;
  1383. resource.id = resource.id.replace(/\s/g, '_');
  1384. resourceView = new ResourceView({
  1385. model: resource,
  1386. tagName: 'li',
  1387. id: 'resource_' + resource.id,
  1388. className: 'resource',
  1389. auths: auths,
  1390. swaggerOptions: this.options.swaggerOptions
  1391. });
  1392. return $('#resources').append(resourceView.render().el);
  1393. };
  1394. MainView.prototype.clear = function() {
  1395. return $(this.el).html('');
  1396. };
  1397. return MainView;
  1398. })(Backbone.View);
  1399. ResourceView = (function(_super) {
  1400. __extends(ResourceView, _super);
  1401. function ResourceView() {
  1402. _ref3 = ResourceView.__super__.constructor.apply(this, arguments);
  1403. return _ref3;
  1404. }
  1405. ResourceView.prototype.initialize = function(opts) {
  1406. if (opts == null) {
  1407. opts = {};
  1408. }
  1409. this.auths = opts.auths;
  1410. if ("" === this.model.description) {
  1411. return this.model.description = null;
  1412. }
  1413. };
  1414. ResourceView.prototype.render = function() {
  1415. var counter, id, methods, operation, _i, _len, _ref4;
  1416. $(this.el).html(Handlebars.templates.resource(this.model));
  1417. methods = {};
  1418. if (this.model.description) {
  1419. this.model.summary = this.model.description;
  1420. }
  1421. _ref4 = this.model.operationsArray;
  1422. for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
  1423. operation = _ref4[_i];
  1424. counter = 0;
  1425. id = operation.nickname;
  1426. while (typeof methods[id] !== 'undefined') {
  1427. id = id + "_" + counter;
  1428. counter += 1;
  1429. }
  1430. methods[id] = operation;
  1431. operation.nickname = id;
  1432. operation.parentId = this.model.id;
  1433. this.addOperation(operation);
  1434. }
  1435. $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
  1436. $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
  1437. $('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
  1438. return this;
  1439. };
  1440. ResourceView.prototype.addOperation = function(operation) {
  1441. var operationView;
  1442. operation.number = this.number;
  1443. operationView = new OperationView({
  1444. model: operation,
  1445. tagName: 'li',
  1446. className: 'endpoint',
  1447. swaggerOptions: this.options.swaggerOptions,
  1448. auths: this.auths
  1449. });
  1450. $('.endpoints', $(this.el)).append(operationView.render().el);
  1451. return this.number++;
  1452. };
  1453. ResourceView.prototype.callDocs = function(fnName, e) {
  1454. e.preventDefault();
  1455. return Docs[fnName](e.currentTarget.getAttribute('data-id'));
  1456. };
  1457. return ResourceView;
  1458. })(Backbone.View);
  1459. OperationView = (function(_super) {
  1460. __extends(OperationView, _super);
  1461. function OperationView() {
  1462. _ref4 = OperationView.__super__.constructor.apply(this, arguments);
  1463. return _ref4;
  1464. }
  1465. OperationView.prototype.invocationUrl = null;
  1466. OperationView.prototype.events = {
  1467. 'submit .sandbox': 'submitOperation',
  1468. 'click .submit': 'submitOperation',
  1469. 'click .response_hider': 'hideResponse',
  1470. 'click .toggleOperation': 'toggleOperationContent',
  1471. 'mouseenter .api-ic': 'mouseEnter',
  1472. 'mouseout .api-ic': 'mouseExit'
  1473. };
  1474. OperationView.prototype.initialize = function(opts) {
  1475. if (opts == null) {
  1476. opts = {};
  1477. }
  1478. this.auths = opts.auths;
  1479. return this;
  1480. };
  1481. OperationView.prototype.mouseEnter = function(e) {
  1482. var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
  1483. elem = $(e.currentTarget.parentNode).find('#api_information_panel');
  1484. x = e.pageX;
  1485. y = e.pageY;
  1486. scX = $(window).scrollLeft();
  1487. scY = $(window).scrollTop();
  1488. scMaxX = scX + $(window).width();
  1489. scMaxY = scY + $(window).height();
  1490. wd = elem.width();
  1491. hgh = elem.height();
  1492. if (x + wd > scMaxX) {
  1493. x = scMaxX - wd;
  1494. }
  1495. if (x < scX) {
  1496. x = scX;
  1497. }
  1498. if (y + hgh > scMaxY) {
  1499. y = scMaxY - hgh;
  1500. }
  1501. if (y < scY) {
  1502. y = scY;
  1503. }
  1504. pos = {};
  1505. pos.top = y;
  1506. pos.left = x;
  1507. elem.css(pos);
  1508. return $(e.currentTarget.parentNode).find('#api_information_panel').show();
  1509. };
  1510. OperationView.prototype.mouseExit = function(e) {
  1511. return $(e.currentTarget.parentNode).find('#api_information_panel').hide();
  1512. };
  1513. OperationView.prototype.render = function() {
  1514. var a, auth, auths, code, contentTypeModel, isMethodSubmissionSupported, k, key, o, param, ref, responseContentTypeView, responseSignatureView, schema, schemaObj, signatureModel, statusCode, type, v, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref10, _ref11, _ref5, _ref6, _ref7, _ref8, _ref9;
  1515. isMethodSubmissionSupported = true;
  1516. if (!isMethodSubmissionSupported) {
  1517. this.model.isReadOnly = true;
  1518. }
  1519. this.model.description = this.model.description || this.model.notes;
  1520. if (this.model.description) {
  1521. this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
  1522. }
  1523. this.model.oauth = null;
  1524. if (this.model.authorizations) {
  1525. if (Array.isArray(this.model.authorizations)) {
  1526. _ref5 = this.model.authorizations;
  1527. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1528. auths = _ref5[_i];
  1529. for (key in auths) {
  1530. auth = auths[key];
  1531. for (a in this.auths) {
  1532. auth = this.auths[a];
  1533. if (auth.type === 'oauth2') {
  1534. this.model.oauth = {};
  1535. this.model.oauth.scopes = [];
  1536. _ref6 = auth.value.scopes;
  1537. for (k in _ref6) {
  1538. v = _ref6[k];
  1539. o = {
  1540. scope: k,
  1541. description: v
  1542. };
  1543. this.model.oauth.scopes.push(o);
  1544. }
  1545. }
  1546. }
  1547. }
  1548. }
  1549. } else {
  1550. _ref7 = this.model.authorizations;
  1551. for (k in _ref7) {
  1552. v = _ref7[k];
  1553. if (k === "oauth2") {
  1554. if (this.model.oauth === null) {
  1555. this.model.oauth = {};
  1556. }
  1557. if (this.model.oauth.scopes === void 0) {
  1558. this.model.oauth.scopes = [];
  1559. }
  1560. for (_j = 0, _len1 = v.length; _j < _len1; _j++) {
  1561. o = v[_j];
  1562. this.model.oauth.scopes.push(o);
  1563. }
  1564. }
  1565. }
  1566. }
  1567. }
  1568. if (typeof this.model.responses !== 'undefined') {
  1569. this.model.responseMessages = [];
  1570. _ref8 = this.model.responses;
  1571. for (code in _ref8) {
  1572. value = _ref8[code];
  1573. schema = null;
  1574. schemaObj = this.model.responses[code].schema;
  1575. if (schemaObj && schemaObj['$ref']) {
  1576. schema = schemaObj['$ref'];
  1577. if (schema.indexOf('#/definitions/') === 0) {
  1578. schema = schema.substring('#/definitions/'.length);
  1579. }
  1580. }
  1581. this.model.responseMessages.push({
  1582. code: code,
  1583. message: value.description,
  1584. responseModel: schema
  1585. });
  1586. }
  1587. }
  1588. if (typeof this.model.responseMessages === 'undefined') {
  1589. this.model.responseMessages = [];
  1590. }
  1591. $(this.el).html(Handlebars.templates.operation(this.model));
  1592. if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
  1593. signatureModel = {
  1594. sampleJSON: this.model.responseSampleJSON,
  1595. isParam: false,
  1596. signature: this.model.responseClassSignature
  1597. };
  1598. responseSignatureView = new SignatureView({
  1599. model: signatureModel,
  1600. tagName: 'div'
  1601. });
  1602. $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
  1603. } else {
  1604. this.model.responseClassSignature = 'string';
  1605. $('.model-signature', $(this.el)).html(this.model.type);
  1606. }
  1607. contentTypeModel = {
  1608. isParam: false
  1609. };
  1610. contentTypeModel.consumes = this.model.consumes;
  1611. contentTypeModel.produces = this.model.produces;
  1612. _ref9 = this.model.parameters;
  1613. for (_k = 0, _len2 = _ref9.length; _k < _len2; _k++) {
  1614. param = _ref9[_k];
  1615. type = param.type || param.dataType;
  1616. if (typeof type === 'undefined') {
  1617. schema = param.schema;
  1618. if (schema && schema['$ref']) {
  1619. ref = schema['$ref'];
  1620. if (ref.indexOf('#/definitions/') === 0) {
  1621. type = ref.substring('#/definitions/'.length);
  1622. } else {
  1623. type = ref;
  1624. }
  1625. }
  1626. }
  1627. if (type && type.toLowerCase() === 'file') {
  1628. if (!contentTypeModel.consumes) {
  1629. contentTypeModel.consumes = 'multipart/form-data';
  1630. }
  1631. }
  1632. param.type = type;
  1633. }
  1634. responseContentTypeView = new ResponseContentTypeView({
  1635. model: contentTypeModel
  1636. });
  1637. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1638. _ref10 = this.model.parameters;
  1639. for (_l = 0, _len3 = _ref10.length; _l < _len3; _l++) {
  1640. param = _ref10[_l];
  1641. this.addParameter(param, contentTypeModel.consumes);
  1642. }
  1643. _ref11 = this.model.responseMessages;
  1644. for (_m = 0, _len4 = _ref11.length; _m < _len4; _m++) {
  1645. statusCode = _ref11[_m];
  1646. this.addStatusCode(statusCode);
  1647. }
  1648. return this;
  1649. };
  1650. OperationView.prototype.addParameter = function(param, consumes) {
  1651. var paramView;
  1652. param.consumes = consumes;
  1653. paramView = new ParameterView({
  1654. model: param,
  1655. tagName: 'tr',
  1656. readOnly: this.model.isReadOnly
  1657. });
  1658. return $('.operation-params', $(this.el)).append(paramView.render().el);
  1659. };
  1660. OperationView.prototype.addStatusCode = function(statusCode) {
  1661. var statusCodeView;
  1662. statusCodeView = new StatusCodeView({
  1663. model: statusCode,
  1664. tagName: 'tr'
  1665. });
  1666. return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
  1667. };
  1668. OperationView.prototype.submitOperation = function(e) {
  1669. var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
  1670. if (e != null) {
  1671. e.preventDefault();
  1672. }
  1673. form = $('.sandbox', $(this.el));
  1674. error_free = true;
  1675. form.find("input.required").each(function() {
  1676. var _this = this;
  1677. $(this).removeClass("error");
  1678. if (jQuery.trim($(this).val()) === "") {
  1679. $(this).addClass("error");
  1680. $(this).wiggle({
  1681. callback: function() {
  1682. return $(_this).focus();
  1683. }
  1684. });
  1685. return error_free = false;
  1686. }
  1687. });
  1688. form.find("textarea.required").each(function() {
  1689. var _this = this;
  1690. $(this).removeClass("error");
  1691. if (jQuery.trim($(this).val()) === "") {
  1692. $(this).addClass("error");
  1693. $(this).wiggle({
  1694. callback: function() {
  1695. return $(_this).focus();
  1696. }
  1697. });
  1698. return error_free = false;
  1699. }
  1700. });
  1701. if (error_free) {
  1702. map = {};
  1703. opts = {
  1704. parent: this
  1705. };
  1706. isFileUpload = false;
  1707. _ref5 = form.find("input");
  1708. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1709. o = _ref5[_i];
  1710. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1711. map[o.name] = o.value;
  1712. }
  1713. if (o.type === "file") {
  1714. isFileUpload = true;
  1715. }
  1716. }
  1717. _ref6 = form.find("textarea");
  1718. for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
  1719. o = _ref6[_j];
  1720. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1721. map[o.name] = o.value;
  1722. }
  1723. }
  1724. _ref7 = form.find("select");
  1725. for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
  1726. o = _ref7[_k];
  1727. val = this.getSelectedValue(o);
  1728. if ((val != null) && jQuery.trim(val).length > 0) {
  1729. map[o.name] = val;
  1730. }
  1731. }
  1732. opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
  1733. opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
  1734. $(".response_throbber", $(this.el)).show();
  1735. if (isFileUpload) {
  1736. return this.handleFileUpload(map, form);
  1737. } else {
  1738. return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
  1739. }
  1740. }
  1741. };
  1742. OperationView.prototype.success = function(response, parent) {
  1743. return parent.showCompleteStatus(response);
  1744. };
  1745. OperationView.prototype.handleFileUpload = function(map, form) {
  1746. var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
  1747. _this = this;
  1748. _ref5 = form.serializeArray();
  1749. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1750. o = _ref5[_i];
  1751. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1752. map[o.name] = o.value;
  1753. }
  1754. }
  1755. bodyParam = new FormData();
  1756. params = 0;
  1757. _ref6 = this.model.parameters;
  1758. for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
  1759. param = _ref6[_j];
  1760. if (param.paramType === 'form') {
  1761. if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
  1762. bodyParam.append(param.name, map[param.name]);
  1763. }
  1764. }
  1765. }
  1766. headerParams = {};
  1767. _ref7 = this.model.parameters;
  1768. for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
  1769. param = _ref7[_k];
  1770. if (param.paramType === 'header') {
  1771. headerParams[param.name] = map[param.name];
  1772. }
  1773. }
  1774. _ref8 = form.find('input[type~="file"]');
  1775. for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
  1776. el = _ref8[_l];
  1777. if (typeof el.files[0] !== 'undefined') {
  1778. bodyParam.append($(el).attr('name'), el.files[0]);
  1779. params += 1;
  1780. }
  1781. }
  1782. this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
  1783. $(".request_url", $(this.el)).html("<pre></pre>");
  1784. $(".request_url pre", $(this.el)).text(this.invocationUrl);
  1785. obj = {
  1786. type: this.model.method,
  1787. url: this.invocationUrl,
  1788. headers: headerParams,
  1789. data: bodyParam,
  1790. dataType: 'json',
  1791. contentType: false,
  1792. processData: false,
  1793. error: function(data, textStatus, error) {
  1794. return _this.showErrorStatus(_this.wrap(data), _this);
  1795. },
  1796. success: function(data) {
  1797. return _this.showResponse(data, _this);
  1798. },
  1799. complete: function(data) {
  1800. return _this.showCompleteStatus(_this.wrap(data), _this);
  1801. }
  1802. };
  1803. if (window.authorizations) {
  1804. window.authorizations.apply(obj);
  1805. }
  1806. if (params === 0) {
  1807. obj.data.append("fake", "true");
  1808. }
  1809. jQuery.ajax(obj);
  1810. return false;
  1811. };
  1812. OperationView.prototype.wrap = function(data) {
  1813. var h, headerArray, headers, i, o, _i, _len;
  1814. headers = {};
  1815. headerArray = data.getAllResponseHeaders().split("\r");
  1816. for (_i = 0, _len = headerArray.length; _i < _len; _i++) {
  1817. i = headerArray[_i];
  1818. h = i.split(':');
  1819. if (h[0] !== void 0 && h[1] !== void 0) {
  1820. headers[h[0].trim()] = h[1].trim();
  1821. }
  1822. }
  1823. o = {};
  1824. o.content = {};
  1825. o.content.data = data.responseText;
  1826. o.headers = headers;
  1827. o.request = {};
  1828. o.request.url = this.invocationUrl;
  1829. o.status = data.status;
  1830. return o;
  1831. };
  1832. OperationView.prototype.getSelectedValue = function(select) {
  1833. var opt, options, _i, _len, _ref5;
  1834. if (!select.multiple) {
  1835. return select.value;
  1836. } else {
  1837. options = [];
  1838. _ref5 = select.options;
  1839. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1840. opt = _ref5[_i];
  1841. if (opt.selected) {
  1842. options.push(opt.value);
  1843. }
  1844. }
  1845. if (options.length > 0) {
  1846. return options;
  1847. } else {
  1848. return null;
  1849. }
  1850. }
  1851. };
  1852. OperationView.prototype.hideResponse = function(e) {
  1853. if (e != null) {
  1854. e.preventDefault();
  1855. }
  1856. $(".response", $(this.el)).slideUp();
  1857. return $(".response_hider", $(this.el)).fadeOut();
  1858. };
  1859. OperationView.prototype.showResponse = function(response) {
  1860. var prettyJson;
  1861. prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
  1862. return $(".response_body", $(this.el)).html(escape(prettyJson));
  1863. };
  1864. OperationView.prototype.showErrorStatus = function(data, parent) {
  1865. return parent.showStatus(data);
  1866. };
  1867. OperationView.prototype.showCompleteStatus = function(data, parent) {
  1868. return parent.showStatus(data);
  1869. };
  1870. OperationView.prototype.formatXml = function(xml) {
  1871. var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
  1872. reg = /(>)(<)(\/*)/g;
  1873. wsexp = /[ ]*(.*)[ ]+\n/g;
  1874. contexp = /(<.+>)(.+\n)/g;
  1875. xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
  1876. pad = 0;
  1877. formatted = '';
  1878. lines = xml.split('\n');
  1879. indent = 0;
  1880. lastType = 'other';
  1881. transitions = {
  1882. 'single->single': 0,
  1883. 'single->closing': -1,
  1884. 'single->opening': 0,
  1885. 'single->other': 0,
  1886. 'closing->single': 0,
  1887. 'closing->closing': -1,
  1888. 'closing->opening': 0,
  1889. 'closing->other': 0,
  1890. 'opening->single': 1,
  1891. 'opening->closing': 0,
  1892. 'opening->opening': 1,
  1893. 'opening->other': 1,
  1894. 'other->single': 0,
  1895. 'other->closing': -1,
  1896. 'other->opening': 0,
  1897. 'other->other': 0
  1898. };
  1899. _fn = function(ln) {
  1900. var fromTo, j, key, padding, type, types, value;
  1901. types = {
  1902. single: Boolean(ln.match(/<.+\/>/)),
  1903. closing: Boolean(ln.match(/<\/.+>/)),
  1904. opening: Boolean(ln.match(/<[^!?].*>/))
  1905. };
  1906. type = ((function() {
  1907. var _results;
  1908. _results = [];
  1909. for (key in types) {
  1910. value = types[key];
  1911. if (value) {
  1912. _results.push(key);
  1913. }
  1914. }
  1915. return _results;
  1916. })())[0];
  1917. type = type === void 0 ? 'other' : type;
  1918. fromTo = lastType + '->' + type;
  1919. lastType = type;
  1920. padding = '';
  1921. indent += transitions[fromTo];
  1922. padding = ((function() {
  1923. var _j, _ref5, _results;
  1924. _results = [];
  1925. for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
  1926. _results.push(' ');
  1927. }
  1928. return _results;
  1929. })()).join('');
  1930. if (fromTo === 'opening->closing') {
  1931. return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
  1932. } else {
  1933. return formatted += padding + ln + '\n';
  1934. }
  1935. };
  1936. for (_i = 0, _len = lines.length; _i < _len; _i++) {
  1937. ln = lines[_i];
  1938. _fn(ln);
  1939. }
  1940. return formatted;
  1941. };
  1942. OperationView.prototype.showStatus = function(response) {
  1943. var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url;
  1944. if (response.content === void 0) {
  1945. content = response.data;
  1946. url = response.url;
  1947. } else {
  1948. content = response.content.data;
  1949. url = response.request.url;
  1950. }
  1951. headers = response.headers;
  1952. contentType = null;
  1953. if (headers) {
  1954. contentType = headers["Content-Type"] || headers["content-type"];
  1955. if (contentType) {
  1956. contentType = contentType.split(";")[0].trim();
  1957. }
  1958. }
  1959. if (!content) {
  1960. code = $('<code />').text("no content");
  1961. pre = $('<pre class="json" />').append(code);
  1962. } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
  1963. json = null;
  1964. try {
  1965. json = JSON.stringify(JSON.parse(content), null, " ");
  1966. } catch (_error) {
  1967. e = _error;
  1968. json = "can't parse JSON. Raw result:\n\n" + content;
  1969. }
  1970. code = $('<code />').text(json);
  1971. pre = $('<pre class="json" />').append(code);
  1972. } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
  1973. code = $('<code />').text(this.formatXml(content));
  1974. pre = $('<pre class="xml" />').append(code);
  1975. } else if (contentType === "text/html") {
  1976. code = $('<code />').html(_.escape(content));
  1977. pre = $('<pre class="xml" />').append(code);
  1978. } else if (/^image\//.test(contentType)) {
  1979. pre = $('<img>').attr('src', url);
  1980. } else {
  1981. code = $('<code />').text(content);
  1982. pre = $('<pre class="json" />').append(code);
  1983. }
  1984. response_body = pre;
  1985. $(".request_url", $(this.el)).html("<pre></pre>");
  1986. $(".request_url pre", $(this.el)).text(url);
  1987. $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
  1988. $(".response_body", $(this.el)).html(response_body);
  1989. $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
  1990. $(".response", $(this.el)).slideDown();
  1991. $(".response_hider", $(this.el)).show();
  1992. $(".response_throbber", $(this.el)).hide();
  1993. response_body_el = $('.response_body', $(this.el))[0];
  1994. opts = this.options.swaggerOptions;
  1995. if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
  1996. return response_body_el;
  1997. } else {
  1998. return hljs.highlightBlock(response_body_el);
  1999. }
  2000. };
  2001. OperationView.prototype.toggleOperationContent = function() {
  2002. var elem;
  2003. elem = $('#' + Docs.escapeResourceName(this.model.parentId + "_" + this.model.nickname + "_content"));
  2004. if (elem.is(':visible')) {
  2005. return Docs.collapseOperation(elem);
  2006. } else {
  2007. return Docs.expandOperation(elem);
  2008. }
  2009. };
  2010. return OperationView;
  2011. })(Backbone.View);
  2012. StatusCodeView = (function(_super) {
  2013. __extends(StatusCodeView, _super);
  2014. function StatusCodeView() {
  2015. _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
  2016. return _ref5;
  2017. }
  2018. StatusCodeView.prototype.initialize = function() {};
  2019. StatusCodeView.prototype.render = function() {
  2020. var responseModel, responseModelView, template;
  2021. template = this.template();
  2022. $(this.el).html(template(this.model));
  2023. if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) {
  2024. responseModel = {
  2025. sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2),
  2026. isParam: false,
  2027. signature: swaggerUi.api.models[this.model.responseModel].getMockSignature()
  2028. };
  2029. responseModelView = new SignatureView({
  2030. model: responseModel,
  2031. tagName: 'div'
  2032. });
  2033. $('.model-signature', this.$el).append(responseModelView.render().el);
  2034. } else {
  2035. $('.model-signature', this.$el).html('');
  2036. }
  2037. return this;
  2038. };
  2039. StatusCodeView.prototype.template = function() {
  2040. return Handlebars.templates.status_code;
  2041. };
  2042. return StatusCodeView;
  2043. })(Backbone.View);
  2044. ParameterView = (function(_super) {
  2045. __extends(ParameterView, _super);
  2046. function ParameterView() {
  2047. _ref6 = ParameterView.__super__.constructor.apply(this, arguments);
  2048. return _ref6;
  2049. }
  2050. ParameterView.prototype.initialize = function() {
  2051. return Handlebars.registerHelper('isArray', function(param, opts) {
  2052. if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
  2053. return opts.fn(this);
  2054. } else {
  2055. return opts.inverse(this);
  2056. }
  2057. });
  2058. };
  2059. ParameterView.prototype.render = function() {
  2060. var contentTypeModel, isParam, parameterContentTypeView, ref, responseContentTypeView, schema, signatureModel, signatureView, template, type;
  2061. type = this.model.type || this.model.dataType;
  2062. if (typeof type === 'undefined') {
  2063. schema = this.model.schema;
  2064. if (schema && schema['$ref']) {
  2065. ref = schema['$ref'];
  2066. if (ref.indexOf('#/definitions/') === 0) {
  2067. type = ref.substring('#/definitions/'.length);
  2068. } else {
  2069. type = ref;
  2070. }
  2071. }
  2072. }
  2073. this.model.type = type;
  2074. this.model.paramType = this.model["in"] || this.model.paramType;
  2075. if (this.model.paramType === 'body') {
  2076. this.model.isBody = true;
  2077. }
  2078. if (type && type.toLowerCase() === 'file') {
  2079. this.model.isFile = true;
  2080. }
  2081. this.model["default"] = this.model["default"] || this.model.defaultValue;
  2082. if (this.model.allowableValues) {
  2083. this.model.isList = true;
  2084. }
  2085. template = this.template();
  2086. $(this.el).html(template(this.model));
  2087. signatureModel = {
  2088. sampleJSON: this.model.sampleJSON,
  2089. isParam: true,
  2090. signature: this.model.signature
  2091. };
  2092. if (this.model.sampleJSON) {
  2093. signatureView = new SignatureView({
  2094. model: signatureModel,
  2095. tagName: 'div'
  2096. });
  2097. $('.model-signature', $(this.el)).append(signatureView.render().el);
  2098. } else {
  2099. $('.model-signature', $(this.el)).html(this.model.signature);
  2100. }
  2101. isParam = false;
  2102. if (this.model.isBody) {
  2103. isParam = true;
  2104. }
  2105. contentTypeModel = {
  2106. isParam: isParam
  2107. };
  2108. contentTypeModel.consumes = this.model.consumes;
  2109. if (isParam) {
  2110. parameterContentTypeView = new ParameterContentTypeView({
  2111. model: contentTypeModel
  2112. });
  2113. $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
  2114. } else {
  2115. responseContentTypeView = new ResponseContentTypeView({
  2116. model: contentTypeModel
  2117. });
  2118. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  2119. }
  2120. return this;
  2121. };
  2122. ParameterView.prototype.template = function() {
  2123. if (this.model.isList) {
  2124. return Handlebars.templates.param_list;
  2125. } else {
  2126. if (this.options.readOnly) {
  2127. if (this.model.required) {
  2128. return Handlebars.templates.param_readonly_required;
  2129. } else {
  2130. return Handlebars.templates.param_readonly;
  2131. }
  2132. } else {
  2133. if (this.model.required) {
  2134. return Handlebars.templates.param_required;
  2135. } else {
  2136. return Handlebars.templates.param;
  2137. }
  2138. }
  2139. }
  2140. };
  2141. return ParameterView;
  2142. })(Backbone.View);
  2143. SignatureView = (function(_super) {
  2144. __extends(SignatureView, _super);
  2145. function SignatureView() {
  2146. _ref7 = SignatureView.__super__.constructor.apply(this, arguments);
  2147. return _ref7;
  2148. }
  2149. SignatureView.prototype.events = {
  2150. 'click a.description-link': 'switchToDescription',
  2151. 'click a.snippet-link': 'switchToSnippet',
  2152. 'mousedown .snippet': 'snippetToTextArea'
  2153. };
  2154. SignatureView.prototype.initialize = function() {};
  2155. SignatureView.prototype.render = function() {
  2156. var template;
  2157. template = this.template();
  2158. $(this.el).html(template(this.model));
  2159. this.switchToSnippet();
  2160. this.isParam = this.model.isParam;
  2161. if (this.isParam) {
  2162. $('.notice', $(this.el)).text('Click to set as parameter value');
  2163. }
  2164. return this;
  2165. };
  2166. SignatureView.prototype.template = function() {
  2167. return Handlebars.templates.signature;
  2168. };
  2169. SignatureView.prototype.switchToDescription = function(e) {
  2170. if (e != null) {
  2171. e.preventDefault();
  2172. }
  2173. $(".snippet", $(this.el)).hide();
  2174. $(".description", $(this.el)).show();
  2175. $('.description-link', $(this.el)).addClass('selected');
  2176. return $('.snippet-link', $(this.el)).removeClass('selected');
  2177. };
  2178. SignatureView.prototype.switchToSnippet = function(e) {
  2179. if (e != null) {
  2180. e.preventDefault();
  2181. }
  2182. $(".description", $(this.el)).hide();
  2183. $(".snippet", $(this.el)).show();
  2184. $('.snippet-link', $(this.el)).addClass('selected');
  2185. return $('.description-link', $(this.el)).removeClass('selected');
  2186. };
  2187. SignatureView.prototype.snippetToTextArea = function(e) {
  2188. var textArea;
  2189. if (this.isParam) {
  2190. if (e != null) {
  2191. e.preventDefault();
  2192. }
  2193. textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
  2194. if ($.trim(textArea.val()) === '') {
  2195. return textArea.val(this.model.sampleJSON);
  2196. }
  2197. }
  2198. };
  2199. return SignatureView;
  2200. })(Backbone.View);
  2201. ContentTypeView = (function(_super) {
  2202. __extends(ContentTypeView, _super);
  2203. function ContentTypeView() {
  2204. _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
  2205. return _ref8;
  2206. }
  2207. ContentTypeView.prototype.initialize = function() {};
  2208. ContentTypeView.prototype.render = function() {
  2209. var template;
  2210. template = this.template();
  2211. $(this.el).html(template(this.model));
  2212. $('label[for=contentType]', $(this.el)).text('Response Content Type');
  2213. return this;
  2214. };
  2215. ContentTypeView.prototype.template = function() {
  2216. return Handlebars.templates.content_type;
  2217. };
  2218. return ContentTypeView;
  2219. })(Backbone.View);
  2220. ResponseContentTypeView = (function(_super) {
  2221. __extends(ResponseContentTypeView, _super);
  2222. function ResponseContentTypeView() {
  2223. _ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
  2224. return _ref9;
  2225. }
  2226. ResponseContentTypeView.prototype.initialize = function() {};
  2227. ResponseContentTypeView.prototype.render = function() {
  2228. var template;
  2229. template = this.template();
  2230. $(this.el).html(template(this.model));
  2231. $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
  2232. return this;
  2233. };
  2234. ResponseContentTypeView.prototype.template = function() {
  2235. return Handlebars.templates.response_content_type;
  2236. };
  2237. return ResponseContentTypeView;
  2238. })(Backbone.View);
  2239. ParameterContentTypeView = (function(_super) {
  2240. __extends(ParameterContentTypeView, _super);
  2241. function ParameterContentTypeView() {
  2242. _ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
  2243. return _ref10;
  2244. }
  2245. ParameterContentTypeView.prototype.initialize = function() {};
  2246. ParameterContentTypeView.prototype.render = function() {
  2247. var template;
  2248. template = this.template();
  2249. $(this.el).html(template(this.model));
  2250. $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
  2251. return this;
  2252. };
  2253. ParameterContentTypeView.prototype.template = function() {
  2254. return Handlebars.templates.parameter_content_type;
  2255. };
  2256. return ParameterContentTypeView;
  2257. })(Backbone.View);
  2258. ApiKeyButton = (function(_super) {
  2259. __extends(ApiKeyButton, _super);
  2260. function ApiKeyButton() {
  2261. _ref11 = ApiKeyButton.__super__.constructor.apply(this, arguments);
  2262. return _ref11;
  2263. }
  2264. ApiKeyButton.prototype.initialize = function() {};
  2265. ApiKeyButton.prototype.render = function() {
  2266. var template;
  2267. template = this.template();
  2268. $(this.el).html(template(this.model));
  2269. return this;
  2270. };
  2271. ApiKeyButton.prototype.events = {
  2272. "click #apikey_button": "toggleApiKeyContainer",
  2273. "click #apply_api_key": "applyApiKey"
  2274. };
  2275. ApiKeyButton.prototype.applyApiKey = function() {
  2276. var elem;
  2277. window.authorizations.add(this.model.name, new ApiKeyAuthorization(this.model.name, $("#input_apiKey_entry").val(), this.model["in"]));
  2278. window.swaggerUi.load();
  2279. return elem = $('#apikey_container').show();
  2280. };
  2281. ApiKeyButton.prototype.toggleApiKeyContainer = function() {
  2282. var elem;
  2283. if ($('#apikey_container').length > 0) {
  2284. elem = $('#apikey_container').first();
  2285. if (elem.is(':visible')) {
  2286. return elem.hide();
  2287. } else {
  2288. $('.auth_container').hide();
  2289. return elem.show();
  2290. }
  2291. }
  2292. };
  2293. ApiKeyButton.prototype.template = function() {
  2294. return Handlebars.templates.apikey_button_view;
  2295. };
  2296. return ApiKeyButton;
  2297. })(Backbone.View);
  2298. BasicAuthButton = (function(_super) {
  2299. __extends(BasicAuthButton, _super);
  2300. function BasicAuthButton() {
  2301. _ref12 = BasicAuthButton.__super__.constructor.apply(this, arguments);
  2302. return _ref12;
  2303. }
  2304. BasicAuthButton.prototype.initialize = function() {};
  2305. BasicAuthButton.prototype.render = function() {
  2306. var template;
  2307. template = this.template();
  2308. $(this.el).html(template(this.model));
  2309. return this;
  2310. };
  2311. BasicAuthButton.prototype.events = {
  2312. "click #basic_auth_button": "togglePasswordContainer",
  2313. "click #apply_basic_auth": "applyPassword"
  2314. };
  2315. BasicAuthButton.prototype.applyPassword = function() {
  2316. var elem, password, username;
  2317. console.log("applying password");
  2318. username = $(".input_username").val();
  2319. password = $(".input_password").val();
  2320. window.authorizations.add(this.model.type, new PasswordAuthorization("basic", username, password));
  2321. window.swaggerUi.load();
  2322. return elem = $('#basic_auth_container').hide();
  2323. };
  2324. BasicAuthButton.prototype.togglePasswordContainer = function() {
  2325. var elem;
  2326. if ($('#basic_auth_container').length > 0) {
  2327. elem = $('#basic_auth_container').show();
  2328. if (elem.is(':visible')) {
  2329. return elem.slideUp();
  2330. } else {
  2331. $('.auth_container').hide();
  2332. return elem.show();
  2333. }
  2334. }
  2335. };
  2336. BasicAuthButton.prototype.template = function() {
  2337. return Handlebars.templates.basic_auth_button_view;
  2338. };
  2339. return BasicAuthButton;
  2340. })(Backbone.View);
  2341. }).call(this);