您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

2673 行
102 KiB

  1. // swagger-ui.js
  2. // version 2.1.0-alpha.6
  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' 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' 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.render = function() {
  1163. var _this = this;
  1164. this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
  1165. this.mainView = new MainView({
  1166. model: this.api,
  1167. el: $('#' + this.dom_id),
  1168. swaggerOptions: this.options
  1169. }).render();
  1170. this.showMessage();
  1171. switch (this.options.docExpansion) {
  1172. case "full":
  1173. Docs.expandOperationsForResource('');
  1174. break;
  1175. case "list":
  1176. Docs.collapseOperationsForResource('');
  1177. }
  1178. if (this.options.onComplete) {
  1179. this.options.onComplete(this.api, this);
  1180. }
  1181. return setTimeout(function() {
  1182. return Docs.shebang();
  1183. }, 400);
  1184. };
  1185. SwaggerUi.prototype.buildUrl = function(base, url) {
  1186. var endOfPath, parts;
  1187. log("base is " + base);
  1188. if (url.indexOf("/") === 0) {
  1189. parts = base.split("/");
  1190. base = parts[0] + "//" + parts[2];
  1191. return base + url;
  1192. } else {
  1193. endOfPath = base.length;
  1194. if (base.indexOf("?") > -1) {
  1195. endOfPath = Math.min(endOfPath, base.indexOf("?"));
  1196. }
  1197. if (base.indexOf("#") > -1) {
  1198. endOfPath = Math.min(endOfPath, base.indexOf("#"));
  1199. }
  1200. base = base.substring(0, endOfPath);
  1201. if (base.indexOf("/", base.length - 1) !== -1) {
  1202. return base + url;
  1203. }
  1204. return base + "/" + url;
  1205. }
  1206. };
  1207. SwaggerUi.prototype.showMessage = function(data) {
  1208. if (data == null) {
  1209. data = '';
  1210. }
  1211. $('#message-bar').removeClass('message-fail');
  1212. $('#message-bar').addClass('message-success');
  1213. return $('#message-bar').html(data);
  1214. };
  1215. SwaggerUi.prototype.onLoadFailure = function(data) {
  1216. var val;
  1217. if (data == null) {
  1218. data = '';
  1219. }
  1220. $('#message-bar').removeClass('message-success');
  1221. $('#message-bar').addClass('message-fail');
  1222. val = $('#message-bar').html(data);
  1223. if (this.options.onFailure != null) {
  1224. this.options.onFailure(data);
  1225. }
  1226. return val;
  1227. };
  1228. return SwaggerUi;
  1229. })(Backbone.Router);
  1230. window.SwaggerUi = SwaggerUi;
  1231. HeaderView = (function(_super) {
  1232. __extends(HeaderView, _super);
  1233. function HeaderView() {
  1234. _ref1 = HeaderView.__super__.constructor.apply(this, arguments);
  1235. return _ref1;
  1236. }
  1237. HeaderView.prototype.events = {
  1238. 'click #show-pet-store-icon': 'showPetStore',
  1239. 'click #show-wordnik-dev-icon': 'showWordnikDev',
  1240. 'click #explore': 'showCustom',
  1241. 'keyup #input_baseUrl': 'showCustomOnKeyup',
  1242. 'keyup #input_apiKey': 'showCustomOnKeyup'
  1243. };
  1244. HeaderView.prototype.initialize = function() {};
  1245. HeaderView.prototype.showPetStore = function(e) {
  1246. return this.trigger('update-swagger-ui', {
  1247. url: "http://petstore.swagger.wordnik.com/api/api-docs"
  1248. });
  1249. };
  1250. HeaderView.prototype.showWordnikDev = function(e) {
  1251. return this.trigger('update-swagger-ui', {
  1252. url: "http://api.wordnik.com/v4/resources.json"
  1253. });
  1254. };
  1255. HeaderView.prototype.showCustomOnKeyup = function(e) {
  1256. if (e.keyCode === 13) {
  1257. return this.showCustom();
  1258. }
  1259. };
  1260. HeaderView.prototype.showCustom = function(e) {
  1261. if (e != null) {
  1262. e.preventDefault();
  1263. }
  1264. return this.trigger('update-swagger-ui', {
  1265. url: $('#input_baseUrl').val(),
  1266. apiKey: $('#input_apiKey').val()
  1267. });
  1268. };
  1269. HeaderView.prototype.update = function(url, apiKey, trigger) {
  1270. if (trigger == null) {
  1271. trigger = false;
  1272. }
  1273. $('#input_baseUrl').val(url);
  1274. if (trigger) {
  1275. return this.trigger('update-swagger-ui', {
  1276. url: url
  1277. });
  1278. }
  1279. };
  1280. return HeaderView;
  1281. })(Backbone.View);
  1282. MainView = (function(_super) {
  1283. var sorters;
  1284. __extends(MainView, _super);
  1285. function MainView() {
  1286. _ref2 = MainView.__super__.constructor.apply(this, arguments);
  1287. return _ref2;
  1288. }
  1289. sorters = {
  1290. 'alpha': function(a, b) {
  1291. return a.path.localeCompare(b.path);
  1292. },
  1293. 'method': function(a, b) {
  1294. return a.method.localeCompare(b.method);
  1295. }
  1296. };
  1297. MainView.prototype.initialize = function(opts) {
  1298. var auth, key, name, url, value, _ref3;
  1299. if (opts == null) {
  1300. opts = {};
  1301. }
  1302. this.model.auths = [];
  1303. _ref3 = this.model.securityDefinitions;
  1304. for (key in _ref3) {
  1305. value = _ref3[key];
  1306. auth = {
  1307. name: key,
  1308. type: value.type,
  1309. value: value
  1310. };
  1311. this.model.auths.push(auth);
  1312. }
  1313. if (this.model.info && this.model.info.license && typeof this.model.info.license === 'string') {
  1314. name = this.model.info.license;
  1315. url = this.model.info.licenseUrl;
  1316. this.model.info.license = {};
  1317. this.model.info.license.name = name;
  1318. this.model.info.license.url = url;
  1319. }
  1320. if (!this.model.info) {
  1321. this.model.info = {};
  1322. }
  1323. if (!this.model.info.version) {
  1324. this.model.info.version = this.model.apiVersion;
  1325. }
  1326. if (this.model.swaggerVersion === "2.0") {
  1327. if ("validatorUrl" in opts.swaggerOptions) {
  1328. return this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
  1329. } else if (this.model.url.indexOf("localhost") > 0) {
  1330. return this.model.validatorUrl = null;
  1331. } else {
  1332. return this.model.validatorUrl = "http://online.swagger.io/validator";
  1333. }
  1334. }
  1335. };
  1336. MainView.prototype.render = function() {
  1337. var auth, button, counter, id, name, resource, resources, _i, _len, _ref3;
  1338. if (this.model.securityDefinitions) {
  1339. for (name in this.model.securityDefinitions) {
  1340. auth = this.model.securityDefinitions[name];
  1341. if (auth.type === "apiKey" && $("#apikey_button").length === 0) {
  1342. button = new ApiKeyButton({
  1343. model: auth
  1344. }).render().el;
  1345. $('.auth_main_container').append(button);
  1346. }
  1347. if (auth.type === "basicAuth" && $("#basic_auth_button").length === 0) {
  1348. button = new BasicAuthButton({
  1349. model: auth
  1350. }).render().el;
  1351. $('.auth_main_container').append(button);
  1352. }
  1353. }
  1354. }
  1355. $(this.el).html(Handlebars.templates.main(this.model));
  1356. resources = {};
  1357. counter = 0;
  1358. _ref3 = this.model.apisArray;
  1359. for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
  1360. resource = _ref3[_i];
  1361. id = resource.name;
  1362. while (typeof resources[id] !== 'undefined') {
  1363. id = id + "_" + counter;
  1364. counter += 1;
  1365. }
  1366. resource.id = id;
  1367. resources[id] = resource;
  1368. this.addResource(resource, this.model.auths);
  1369. }
  1370. return this;
  1371. };
  1372. MainView.prototype.addResource = function(resource, auths) {
  1373. var resourceView;
  1374. resource.id = resource.id.replace(/\s/g, '_');
  1375. resourceView = new ResourceView({
  1376. model: resource,
  1377. tagName: 'li',
  1378. id: 'resource_' + resource.id,
  1379. className: 'resource',
  1380. auths: auths,
  1381. swaggerOptions: this.options.swaggerOptions
  1382. });
  1383. return $('#resources').append(resourceView.render().el);
  1384. };
  1385. MainView.prototype.clear = function() {
  1386. return $(this.el).html('');
  1387. };
  1388. return MainView;
  1389. })(Backbone.View);
  1390. ResourceView = (function(_super) {
  1391. __extends(ResourceView, _super);
  1392. function ResourceView() {
  1393. _ref3 = ResourceView.__super__.constructor.apply(this, arguments);
  1394. return _ref3;
  1395. }
  1396. ResourceView.prototype.initialize = function(opts) {
  1397. if (opts == null) {
  1398. opts = {};
  1399. }
  1400. this.auths = opts.auths;
  1401. if ("" === this.model.description) {
  1402. return this.model.description = null;
  1403. }
  1404. };
  1405. ResourceView.prototype.render = function() {
  1406. var counter, id, methods, operation, _i, _len, _ref4;
  1407. $(this.el).html(Handlebars.templates.resource(this.model));
  1408. methods = {};
  1409. if (this.model.description) {
  1410. this.model.summary = this.model.description;
  1411. }
  1412. _ref4 = this.model.operationsArray;
  1413. for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
  1414. operation = _ref4[_i];
  1415. counter = 0;
  1416. id = operation.nickname;
  1417. while (typeof methods[id] !== 'undefined') {
  1418. id = id + "_" + counter;
  1419. counter += 1;
  1420. }
  1421. methods[id] = operation;
  1422. operation.nickname = id;
  1423. operation.parentId = this.model.id;
  1424. this.addOperation(operation);
  1425. }
  1426. $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
  1427. $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
  1428. $('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
  1429. return this;
  1430. };
  1431. ResourceView.prototype.addOperation = function(operation) {
  1432. var operationView;
  1433. operation.number = this.number;
  1434. operationView = new OperationView({
  1435. model: operation,
  1436. tagName: 'li',
  1437. className: 'endpoint',
  1438. swaggerOptions: this.options.swaggerOptions,
  1439. auths: this.auths
  1440. });
  1441. $('.endpoints', $(this.el)).append(operationView.render().el);
  1442. return this.number++;
  1443. };
  1444. ResourceView.prototype.callDocs = function(fnName, e) {
  1445. e.preventDefault();
  1446. return Docs[fnName](e.currentTarget.getAttribute('data-id'));
  1447. };
  1448. return ResourceView;
  1449. })(Backbone.View);
  1450. OperationView = (function(_super) {
  1451. __extends(OperationView, _super);
  1452. function OperationView() {
  1453. _ref4 = OperationView.__super__.constructor.apply(this, arguments);
  1454. return _ref4;
  1455. }
  1456. OperationView.prototype.invocationUrl = null;
  1457. OperationView.prototype.events = {
  1458. 'submit .sandbox': 'submitOperation',
  1459. 'click .submit': 'submitOperation',
  1460. 'click .response_hider': 'hideResponse',
  1461. 'click .toggleOperation': 'toggleOperationContent',
  1462. 'mouseenter .api-ic': 'mouseEnter',
  1463. 'mouseout .api-ic': 'mouseExit'
  1464. };
  1465. OperationView.prototype.initialize = function(opts) {
  1466. if (opts == null) {
  1467. opts = {};
  1468. }
  1469. this.auths = opts.auths;
  1470. return this;
  1471. };
  1472. OperationView.prototype.mouseEnter = function(e) {
  1473. var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
  1474. elem = $(e.currentTarget.parentNode).find('#api_information_panel');
  1475. x = e.pageX;
  1476. y = e.pageY;
  1477. scX = $(window).scrollLeft();
  1478. scY = $(window).scrollTop();
  1479. scMaxX = scX + $(window).width();
  1480. scMaxY = scY + $(window).height();
  1481. wd = elem.width();
  1482. hgh = elem.height();
  1483. if (x + wd > scMaxX) {
  1484. x = scMaxX - wd;
  1485. }
  1486. if (x < scX) {
  1487. x = scX;
  1488. }
  1489. if (y + hgh > scMaxY) {
  1490. y = scMaxY - hgh;
  1491. }
  1492. if (y < scY) {
  1493. y = scY;
  1494. }
  1495. pos = {};
  1496. pos.top = y;
  1497. pos.left = x;
  1498. elem.css(pos);
  1499. return $(e.currentTarget.parentNode).find('#api_information_panel').show();
  1500. };
  1501. OperationView.prototype.mouseExit = function(e) {
  1502. return $(e.currentTarget.parentNode).find('#api_information_panel').hide();
  1503. };
  1504. OperationView.prototype.render = function() {
  1505. 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;
  1506. isMethodSubmissionSupported = true;
  1507. if (!isMethodSubmissionSupported) {
  1508. this.model.isReadOnly = true;
  1509. }
  1510. this.model.description = this.model.description || this.model.notes;
  1511. if (this.model.description) {
  1512. this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
  1513. }
  1514. this.model.oauth = null;
  1515. if (this.model.authorizations) {
  1516. if (Array.isArray(this.model.authorizations)) {
  1517. _ref5 = this.model.authorizations;
  1518. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1519. auths = _ref5[_i];
  1520. for (key in auths) {
  1521. auth = auths[key];
  1522. for (a in this.auths) {
  1523. auth = this.auths[a];
  1524. if (auth.type === 'oauth2') {
  1525. this.model.oauth = {};
  1526. this.model.oauth.scopes = [];
  1527. _ref6 = auth.value.scopes;
  1528. for (k in _ref6) {
  1529. v = _ref6[k];
  1530. o = {
  1531. scope: k,
  1532. description: v
  1533. };
  1534. this.model.oauth.scopes.push(o);
  1535. }
  1536. }
  1537. }
  1538. }
  1539. }
  1540. } else {
  1541. _ref7 = this.model.authorizations;
  1542. for (k in _ref7) {
  1543. v = _ref7[k];
  1544. if (k === "oauth2") {
  1545. if (this.model.oauth === null) {
  1546. this.model.oauth = {};
  1547. }
  1548. if (this.model.oauth.scopes === void 0) {
  1549. this.model.oauth.scopes = [];
  1550. }
  1551. for (_j = 0, _len1 = v.length; _j < _len1; _j++) {
  1552. o = v[_j];
  1553. this.model.oauth.scopes.push(o);
  1554. }
  1555. }
  1556. }
  1557. }
  1558. }
  1559. if (typeof this.model.responses !== 'undefined') {
  1560. this.model.responseMessages = [];
  1561. _ref8 = this.model.responses;
  1562. for (code in _ref8) {
  1563. value = _ref8[code];
  1564. schema = null;
  1565. schemaObj = this.model.responses[code].schema;
  1566. if (schemaObj && schemaObj['$ref']) {
  1567. schema = schemaObj['$ref'];
  1568. if (schema.indexOf('#/definitions/') === 0) {
  1569. schema = schema.substring('#/definitions/'.length);
  1570. }
  1571. }
  1572. this.model.responseMessages.push({
  1573. code: code,
  1574. message: value.description,
  1575. responseModel: schema
  1576. });
  1577. }
  1578. }
  1579. if (typeof this.model.responseMessages === 'undefined') {
  1580. this.model.responseMessages = [];
  1581. }
  1582. $(this.el).html(Handlebars.templates.operation(this.model));
  1583. if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
  1584. signatureModel = {
  1585. sampleJSON: this.model.responseSampleJSON,
  1586. isParam: false,
  1587. signature: this.model.responseClassSignature
  1588. };
  1589. responseSignatureView = new SignatureView({
  1590. model: signatureModel,
  1591. tagName: 'div'
  1592. });
  1593. $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
  1594. } else {
  1595. this.model.responseClassSignature = 'string';
  1596. $('.model-signature', $(this.el)).html(this.model.type);
  1597. }
  1598. contentTypeModel = {
  1599. isParam: false
  1600. };
  1601. contentTypeModel.consumes = this.model.consumes;
  1602. contentTypeModel.produces = this.model.produces;
  1603. _ref9 = this.model.parameters;
  1604. for (_k = 0, _len2 = _ref9.length; _k < _len2; _k++) {
  1605. param = _ref9[_k];
  1606. type = param.type || param.dataType;
  1607. if (typeof type === 'undefined') {
  1608. schema = param.schema;
  1609. if (schema && schema['$ref']) {
  1610. ref = schema['$ref'];
  1611. if (ref.indexOf('#/definitions/') === 0) {
  1612. type = ref.substring('#/definitions/'.length);
  1613. } else {
  1614. type = ref;
  1615. }
  1616. }
  1617. }
  1618. if (type && type.toLowerCase() === 'file') {
  1619. if (!contentTypeModel.consumes) {
  1620. contentTypeModel.consumes = 'multipart/form-data';
  1621. }
  1622. }
  1623. param.type = type;
  1624. }
  1625. responseContentTypeView = new ResponseContentTypeView({
  1626. model: contentTypeModel
  1627. });
  1628. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  1629. _ref10 = this.model.parameters;
  1630. for (_l = 0, _len3 = _ref10.length; _l < _len3; _l++) {
  1631. param = _ref10[_l];
  1632. this.addParameter(param, contentTypeModel.consumes);
  1633. }
  1634. _ref11 = this.model.responseMessages;
  1635. for (_m = 0, _len4 = _ref11.length; _m < _len4; _m++) {
  1636. statusCode = _ref11[_m];
  1637. this.addStatusCode(statusCode);
  1638. }
  1639. return this;
  1640. };
  1641. OperationView.prototype.addParameter = function(param, consumes) {
  1642. var paramView;
  1643. param.consumes = consumes;
  1644. paramView = new ParameterView({
  1645. model: param,
  1646. tagName: 'tr',
  1647. readOnly: this.model.isReadOnly
  1648. });
  1649. return $('.operation-params', $(this.el)).append(paramView.render().el);
  1650. };
  1651. OperationView.prototype.addStatusCode = function(statusCode) {
  1652. var statusCodeView;
  1653. statusCodeView = new StatusCodeView({
  1654. model: statusCode,
  1655. tagName: 'tr'
  1656. });
  1657. return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
  1658. };
  1659. OperationView.prototype.submitOperation = function(e) {
  1660. var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
  1661. if (e != null) {
  1662. e.preventDefault();
  1663. }
  1664. form = $('.sandbox', $(this.el));
  1665. error_free = true;
  1666. form.find("input.required").each(function() {
  1667. var _this = this;
  1668. $(this).removeClass("error");
  1669. if (jQuery.trim($(this).val()) === "") {
  1670. $(this).addClass("error");
  1671. $(this).wiggle({
  1672. callback: function() {
  1673. return $(_this).focus();
  1674. }
  1675. });
  1676. return error_free = false;
  1677. }
  1678. });
  1679. if (error_free) {
  1680. map = {};
  1681. opts = {
  1682. parent: this
  1683. };
  1684. isFileUpload = false;
  1685. _ref5 = form.find("input");
  1686. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1687. o = _ref5[_i];
  1688. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1689. map[o.name] = o.value;
  1690. }
  1691. if (o.type === "file") {
  1692. isFileUpload = true;
  1693. }
  1694. }
  1695. _ref6 = form.find("textarea");
  1696. for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
  1697. o = _ref6[_j];
  1698. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1699. map[o.name] = o.value;
  1700. }
  1701. }
  1702. _ref7 = form.find("select");
  1703. for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
  1704. o = _ref7[_k];
  1705. val = this.getSelectedValue(o);
  1706. if ((val != null) && jQuery.trim(val).length > 0) {
  1707. map[o.name] = val;
  1708. }
  1709. }
  1710. opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
  1711. opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
  1712. $(".response_throbber", $(this.el)).show();
  1713. if (isFileUpload) {
  1714. return this.handleFileUpload(map, form);
  1715. } else {
  1716. return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
  1717. }
  1718. }
  1719. };
  1720. OperationView.prototype.success = function(response, parent) {
  1721. return parent.showCompleteStatus(response);
  1722. };
  1723. OperationView.prototype.handleFileUpload = function(map, form) {
  1724. var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
  1725. _this = this;
  1726. _ref5 = form.serializeArray();
  1727. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1728. o = _ref5[_i];
  1729. if ((o.value != null) && jQuery.trim(o.value).length > 0) {
  1730. map[o.name] = o.value;
  1731. }
  1732. }
  1733. bodyParam = new FormData();
  1734. params = 0;
  1735. _ref6 = this.model.parameters;
  1736. for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
  1737. param = _ref6[_j];
  1738. if (param.paramType === 'form') {
  1739. if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
  1740. bodyParam.append(param.name, map[param.name]);
  1741. }
  1742. }
  1743. }
  1744. headerParams = {};
  1745. _ref7 = this.model.parameters;
  1746. for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
  1747. param = _ref7[_k];
  1748. if (param.paramType === 'header') {
  1749. headerParams[param.name] = map[param.name];
  1750. }
  1751. }
  1752. _ref8 = form.find('input[type~="file"]');
  1753. for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
  1754. el = _ref8[_l];
  1755. if (typeof el.files[0] !== 'undefined') {
  1756. bodyParam.append($(el).attr('name'), el.files[0]);
  1757. params += 1;
  1758. }
  1759. }
  1760. this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
  1761. $(".request_url", $(this.el)).html("<pre></pre>");
  1762. $(".request_url pre", $(this.el)).text(this.invocationUrl);
  1763. obj = {
  1764. type: this.model.method,
  1765. url: this.invocationUrl,
  1766. headers: headerParams,
  1767. data: bodyParam,
  1768. dataType: 'json',
  1769. contentType: false,
  1770. processData: false,
  1771. error: function(data, textStatus, error) {
  1772. return _this.showErrorStatus(_this.wrap(data), _this);
  1773. },
  1774. success: function(data) {
  1775. return _this.showResponse(data, _this);
  1776. },
  1777. complete: function(data) {
  1778. return _this.showCompleteStatus(_this.wrap(data), _this);
  1779. }
  1780. };
  1781. if (window.authorizations) {
  1782. window.authorizations.apply(obj);
  1783. }
  1784. if (params === 0) {
  1785. obj.data.append("fake", "true");
  1786. }
  1787. jQuery.ajax(obj);
  1788. return false;
  1789. };
  1790. OperationView.prototype.wrap = function(data) {
  1791. var h, headerArray, headers, i, o, _i, _len;
  1792. headers = {};
  1793. headerArray = data.getAllResponseHeaders().split("\r");
  1794. for (_i = 0, _len = headerArray.length; _i < _len; _i++) {
  1795. i = headerArray[_i];
  1796. h = i.split(':');
  1797. if (h[0] !== void 0 && h[1] !== void 0) {
  1798. headers[h[0].trim()] = h[1].trim();
  1799. }
  1800. }
  1801. o = {};
  1802. o.content = {};
  1803. o.content.data = data.responseText;
  1804. o.headers = headers;
  1805. o.request = {};
  1806. o.request.url = this.invocationUrl;
  1807. o.status = data.status;
  1808. return o;
  1809. };
  1810. OperationView.prototype.getSelectedValue = function(select) {
  1811. var opt, options, _i, _len, _ref5;
  1812. if (!select.multiple) {
  1813. return select.value;
  1814. } else {
  1815. options = [];
  1816. _ref5 = select.options;
  1817. for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
  1818. opt = _ref5[_i];
  1819. if (opt.selected) {
  1820. options.push(opt.value);
  1821. }
  1822. }
  1823. if (options.length > 0) {
  1824. return options;
  1825. } else {
  1826. return null;
  1827. }
  1828. }
  1829. };
  1830. OperationView.prototype.hideResponse = function(e) {
  1831. if (e != null) {
  1832. e.preventDefault();
  1833. }
  1834. $(".response", $(this.el)).slideUp();
  1835. return $(".response_hider", $(this.el)).fadeOut();
  1836. };
  1837. OperationView.prototype.showResponse = function(response) {
  1838. var prettyJson;
  1839. prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
  1840. return $(".response_body", $(this.el)).html(escape(prettyJson));
  1841. };
  1842. OperationView.prototype.showErrorStatus = function(data, parent) {
  1843. return parent.showStatus(data);
  1844. };
  1845. OperationView.prototype.showCompleteStatus = function(data, parent) {
  1846. return parent.showStatus(data);
  1847. };
  1848. OperationView.prototype.formatXml = function(xml) {
  1849. var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
  1850. reg = /(>)(<)(\/*)/g;
  1851. wsexp = /[ ]*(.*)[ ]+\n/g;
  1852. contexp = /(<.+>)(.+\n)/g;
  1853. xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
  1854. pad = 0;
  1855. formatted = '';
  1856. lines = xml.split('\n');
  1857. indent = 0;
  1858. lastType = 'other';
  1859. transitions = {
  1860. 'single->single': 0,
  1861. 'single->closing': -1,
  1862. 'single->opening': 0,
  1863. 'single->other': 0,
  1864. 'closing->single': 0,
  1865. 'closing->closing': -1,
  1866. 'closing->opening': 0,
  1867. 'closing->other': 0,
  1868. 'opening->single': 1,
  1869. 'opening->closing': 0,
  1870. 'opening->opening': 1,
  1871. 'opening->other': 1,
  1872. 'other->single': 0,
  1873. 'other->closing': -1,
  1874. 'other->opening': 0,
  1875. 'other->other': 0
  1876. };
  1877. _fn = function(ln) {
  1878. var fromTo, j, key, padding, type, types, value;
  1879. types = {
  1880. single: Boolean(ln.match(/<.+\/>/)),
  1881. closing: Boolean(ln.match(/<\/.+>/)),
  1882. opening: Boolean(ln.match(/<[^!?].*>/))
  1883. };
  1884. type = ((function() {
  1885. var _results;
  1886. _results = [];
  1887. for (key in types) {
  1888. value = types[key];
  1889. if (value) {
  1890. _results.push(key);
  1891. }
  1892. }
  1893. return _results;
  1894. })())[0];
  1895. type = type === void 0 ? 'other' : type;
  1896. fromTo = lastType + '->' + type;
  1897. lastType = type;
  1898. padding = '';
  1899. indent += transitions[fromTo];
  1900. padding = ((function() {
  1901. var _j, _ref5, _results;
  1902. _results = [];
  1903. for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
  1904. _results.push(' ');
  1905. }
  1906. return _results;
  1907. })()).join('');
  1908. if (fromTo === 'opening->closing') {
  1909. return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
  1910. } else {
  1911. return formatted += padding + ln + '\n';
  1912. }
  1913. };
  1914. for (_i = 0, _len = lines.length; _i < _len; _i++) {
  1915. ln = lines[_i];
  1916. _fn(ln);
  1917. }
  1918. return formatted;
  1919. };
  1920. OperationView.prototype.showStatus = function(response) {
  1921. var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url;
  1922. if (response.content === void 0) {
  1923. content = response.data;
  1924. url = response.url;
  1925. } else {
  1926. content = response.content.data;
  1927. url = response.request.url;
  1928. }
  1929. headers = response.headers;
  1930. contentType = null;
  1931. if (headers) {
  1932. contentType = headers["Content-Type"] || headers["content-type"];
  1933. if (contentType) {
  1934. contentType = contentType.split(";")[0].trim();
  1935. }
  1936. }
  1937. if (!content) {
  1938. code = $('<code />').text("no content");
  1939. pre = $('<pre class="json" />').append(code);
  1940. } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
  1941. json = null;
  1942. try {
  1943. json = JSON.stringify(JSON.parse(content), null, " ");
  1944. } catch (_error) {
  1945. e = _error;
  1946. json = "can't parse JSON. Raw result:\n\n" + content;
  1947. }
  1948. code = $('<code />').text(json);
  1949. pre = $('<pre class="json" />').append(code);
  1950. } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
  1951. code = $('<code />').text(this.formatXml(content));
  1952. pre = $('<pre class="xml" />').append(code);
  1953. } else if (contentType === "text/html") {
  1954. code = $('<code />').html(_.escape(content));
  1955. pre = $('<pre class="xml" />').append(code);
  1956. } else if (/^image\//.test(contentType)) {
  1957. pre = $('<img>').attr('src', url);
  1958. } else {
  1959. code = $('<code />').text(content);
  1960. pre = $('<pre class="json" />').append(code);
  1961. }
  1962. response_body = pre;
  1963. $(".request_url", $(this.el)).html("<pre></pre>");
  1964. $(".request_url pre", $(this.el)).text(url);
  1965. $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
  1966. $(".response_body", $(this.el)).html(response_body);
  1967. $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
  1968. $(".response", $(this.el)).slideDown();
  1969. $(".response_hider", $(this.el)).show();
  1970. $(".response_throbber", $(this.el)).hide();
  1971. response_body_el = $('.response_body', $(this.el))[0];
  1972. opts = this.options.swaggerOptions;
  1973. if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
  1974. return response_body_el;
  1975. } else {
  1976. return hljs.highlightBlock(response_body_el);
  1977. }
  1978. };
  1979. OperationView.prototype.toggleOperationContent = function() {
  1980. var elem;
  1981. elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_content");
  1982. if (elem.is(':visible')) {
  1983. return Docs.collapseOperation(elem);
  1984. } else {
  1985. return Docs.expandOperation(elem);
  1986. }
  1987. };
  1988. return OperationView;
  1989. })(Backbone.View);
  1990. StatusCodeView = (function(_super) {
  1991. __extends(StatusCodeView, _super);
  1992. function StatusCodeView() {
  1993. _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
  1994. return _ref5;
  1995. }
  1996. StatusCodeView.prototype.initialize = function() {};
  1997. StatusCodeView.prototype.render = function() {
  1998. var responseModel, responseModelView, template;
  1999. template = this.template();
  2000. $(this.el).html(template(this.model));
  2001. if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) {
  2002. responseModel = {
  2003. sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2),
  2004. isParam: false,
  2005. signature: swaggerUi.api.models[this.model.responseModel].getMockSignature()
  2006. };
  2007. responseModelView = new SignatureView({
  2008. model: responseModel,
  2009. tagName: 'div'
  2010. });
  2011. $('.model-signature', this.$el).append(responseModelView.render().el);
  2012. } else {
  2013. $('.model-signature', this.$el).html('');
  2014. }
  2015. return this;
  2016. };
  2017. StatusCodeView.prototype.template = function() {
  2018. return Handlebars.templates.status_code;
  2019. };
  2020. return StatusCodeView;
  2021. })(Backbone.View);
  2022. ParameterView = (function(_super) {
  2023. __extends(ParameterView, _super);
  2024. function ParameterView() {
  2025. _ref6 = ParameterView.__super__.constructor.apply(this, arguments);
  2026. return _ref6;
  2027. }
  2028. ParameterView.prototype.initialize = function() {
  2029. return Handlebars.registerHelper('isArray', function(param, opts) {
  2030. if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
  2031. return opts.fn(this);
  2032. } else {
  2033. return opts.inverse(this);
  2034. }
  2035. });
  2036. };
  2037. ParameterView.prototype.render = function() {
  2038. var contentTypeModel, isParam, parameterContentTypeView, ref, responseContentTypeView, schema, signatureModel, signatureView, template, type;
  2039. type = this.model.type || this.model.dataType;
  2040. if (typeof type === 'undefined') {
  2041. schema = this.model.schema;
  2042. if (schema && schema['$ref']) {
  2043. ref = schema['$ref'];
  2044. if (ref.indexOf('#/definitions/') === 0) {
  2045. type = ref.substring('#/definitions/'.length);
  2046. } else {
  2047. type = ref;
  2048. }
  2049. }
  2050. }
  2051. this.model.type = type;
  2052. this.model.paramType = this.model["in"] || this.model.paramType;
  2053. if (this.model.paramType === 'body') {
  2054. this.model.isBody = true;
  2055. }
  2056. if (type && type.toLowerCase() === 'file') {
  2057. this.model.isFile = true;
  2058. }
  2059. this.model["default"] = this.model["default"] || this.model.defaultValue;
  2060. if (this.model.allowableValues) {
  2061. this.model.isList = true;
  2062. }
  2063. template = this.template();
  2064. $(this.el).html(template(this.model));
  2065. signatureModel = {
  2066. sampleJSON: this.model.sampleJSON,
  2067. isParam: true,
  2068. signature: this.model.signature
  2069. };
  2070. if (this.model.sampleJSON) {
  2071. signatureView = new SignatureView({
  2072. model: signatureModel,
  2073. tagName: 'div'
  2074. });
  2075. $('.model-signature', $(this.el)).append(signatureView.render().el);
  2076. } else {
  2077. $('.model-signature', $(this.el)).html(this.model.signature);
  2078. }
  2079. isParam = false;
  2080. if (this.model.isBody) {
  2081. isParam = true;
  2082. }
  2083. contentTypeModel = {
  2084. isParam: isParam
  2085. };
  2086. contentTypeModel.consumes = this.model.consumes;
  2087. if (isParam) {
  2088. parameterContentTypeView = new ParameterContentTypeView({
  2089. model: contentTypeModel
  2090. });
  2091. $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
  2092. } else {
  2093. responseContentTypeView = new ResponseContentTypeView({
  2094. model: contentTypeModel
  2095. });
  2096. $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
  2097. }
  2098. return this;
  2099. };
  2100. ParameterView.prototype.template = function() {
  2101. if (this.model.isList) {
  2102. return Handlebars.templates.param_list;
  2103. } else {
  2104. if (this.options.readOnly) {
  2105. if (this.model.required) {
  2106. return Handlebars.templates.param_readonly_required;
  2107. } else {
  2108. return Handlebars.templates.param_readonly;
  2109. }
  2110. } else {
  2111. if (this.model.required) {
  2112. return Handlebars.templates.param_required;
  2113. } else {
  2114. return Handlebars.templates.param;
  2115. }
  2116. }
  2117. }
  2118. };
  2119. return ParameterView;
  2120. })(Backbone.View);
  2121. SignatureView = (function(_super) {
  2122. __extends(SignatureView, _super);
  2123. function SignatureView() {
  2124. _ref7 = SignatureView.__super__.constructor.apply(this, arguments);
  2125. return _ref7;
  2126. }
  2127. SignatureView.prototype.events = {
  2128. 'click a.description-link': 'switchToDescription',
  2129. 'click a.snippet-link': 'switchToSnippet',
  2130. 'mousedown .snippet': 'snippetToTextArea'
  2131. };
  2132. SignatureView.prototype.initialize = function() {};
  2133. SignatureView.prototype.render = function() {
  2134. var template;
  2135. template = this.template();
  2136. $(this.el).html(template(this.model));
  2137. this.switchToSnippet();
  2138. this.isParam = this.model.isParam;
  2139. if (this.isParam) {
  2140. $('.notice', $(this.el)).text('Click to set as parameter value');
  2141. }
  2142. return this;
  2143. };
  2144. SignatureView.prototype.template = function() {
  2145. return Handlebars.templates.signature;
  2146. };
  2147. SignatureView.prototype.switchToDescription = function(e) {
  2148. if (e != null) {
  2149. e.preventDefault();
  2150. }
  2151. $(".snippet", $(this.el)).hide();
  2152. $(".description", $(this.el)).show();
  2153. $('.description-link', $(this.el)).addClass('selected');
  2154. return $('.snippet-link', $(this.el)).removeClass('selected');
  2155. };
  2156. SignatureView.prototype.switchToSnippet = function(e) {
  2157. if (e != null) {
  2158. e.preventDefault();
  2159. }
  2160. $(".description", $(this.el)).hide();
  2161. $(".snippet", $(this.el)).show();
  2162. $('.snippet-link', $(this.el)).addClass('selected');
  2163. return $('.description-link', $(this.el)).removeClass('selected');
  2164. };
  2165. SignatureView.prototype.snippetToTextArea = function(e) {
  2166. var textArea;
  2167. if (this.isParam) {
  2168. if (e != null) {
  2169. e.preventDefault();
  2170. }
  2171. textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
  2172. if ($.trim(textArea.val()) === '') {
  2173. return textArea.val(this.model.sampleJSON);
  2174. }
  2175. }
  2176. };
  2177. return SignatureView;
  2178. })(Backbone.View);
  2179. ContentTypeView = (function(_super) {
  2180. __extends(ContentTypeView, _super);
  2181. function ContentTypeView() {
  2182. _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
  2183. return _ref8;
  2184. }
  2185. ContentTypeView.prototype.initialize = function() {};
  2186. ContentTypeView.prototype.render = function() {
  2187. var template;
  2188. template = this.template();
  2189. $(this.el).html(template(this.model));
  2190. $('label[for=contentType]', $(this.el)).text('Response Content Type');
  2191. return this;
  2192. };
  2193. ContentTypeView.prototype.template = function() {
  2194. return Handlebars.templates.content_type;
  2195. };
  2196. return ContentTypeView;
  2197. })(Backbone.View);
  2198. ResponseContentTypeView = (function(_super) {
  2199. __extends(ResponseContentTypeView, _super);
  2200. function ResponseContentTypeView() {
  2201. _ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
  2202. return _ref9;
  2203. }
  2204. ResponseContentTypeView.prototype.initialize = function() {};
  2205. ResponseContentTypeView.prototype.render = function() {
  2206. var template;
  2207. template = this.template();
  2208. $(this.el).html(template(this.model));
  2209. $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
  2210. return this;
  2211. };
  2212. ResponseContentTypeView.prototype.template = function() {
  2213. return Handlebars.templates.response_content_type;
  2214. };
  2215. return ResponseContentTypeView;
  2216. })(Backbone.View);
  2217. ParameterContentTypeView = (function(_super) {
  2218. __extends(ParameterContentTypeView, _super);
  2219. function ParameterContentTypeView() {
  2220. _ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
  2221. return _ref10;
  2222. }
  2223. ParameterContentTypeView.prototype.initialize = function() {};
  2224. ParameterContentTypeView.prototype.render = function() {
  2225. var template;
  2226. template = this.template();
  2227. $(this.el).html(template(this.model));
  2228. $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
  2229. return this;
  2230. };
  2231. ParameterContentTypeView.prototype.template = function() {
  2232. return Handlebars.templates.parameter_content_type;
  2233. };
  2234. return ParameterContentTypeView;
  2235. })(Backbone.View);
  2236. ApiKeyButton = (function(_super) {
  2237. __extends(ApiKeyButton, _super);
  2238. function ApiKeyButton() {
  2239. _ref11 = ApiKeyButton.__super__.constructor.apply(this, arguments);
  2240. return _ref11;
  2241. }
  2242. ApiKeyButton.prototype.initialize = function() {};
  2243. ApiKeyButton.prototype.render = function() {
  2244. var template;
  2245. template = this.template();
  2246. $(this.el).html(template(this.model));
  2247. return this;
  2248. };
  2249. ApiKeyButton.prototype.events = {
  2250. "click #apikey_button": "toggleApiKeyContainer",
  2251. "click #apply_api_key": "applyApiKey"
  2252. };
  2253. ApiKeyButton.prototype.applyApiKey = function() {
  2254. var elem;
  2255. window.authorizations.add(this.model.name, new ApiKeyAuthorization(this.model.name, $("#input_apiKey_entry").val(), this.model["in"]));
  2256. window.swaggerUi.load();
  2257. return elem = $('#apikey_container').show();
  2258. };
  2259. ApiKeyButton.prototype.toggleApiKeyContainer = function() {
  2260. var elem;
  2261. if ($('#apikey_container').length > 0) {
  2262. elem = $('#apikey_container').first();
  2263. if (elem.is(':visible')) {
  2264. return elem.hide();
  2265. } else {
  2266. $('.auth_container').hide();
  2267. return elem.show();
  2268. }
  2269. }
  2270. };
  2271. ApiKeyButton.prototype.template = function() {
  2272. return Handlebars.templates.apikey_button_view;
  2273. };
  2274. return ApiKeyButton;
  2275. })(Backbone.View);
  2276. BasicAuthButton = (function(_super) {
  2277. __extends(BasicAuthButton, _super);
  2278. function BasicAuthButton() {
  2279. _ref12 = BasicAuthButton.__super__.constructor.apply(this, arguments);
  2280. return _ref12;
  2281. }
  2282. BasicAuthButton.prototype.initialize = function() {};
  2283. BasicAuthButton.prototype.render = function() {
  2284. var template;
  2285. template = this.template();
  2286. $(this.el).html(template(this.model));
  2287. return this;
  2288. };
  2289. BasicAuthButton.prototype.events = {
  2290. "click #basic_auth_button": "togglePasswordContainer",
  2291. "click #apply_basic_auth": "applyPassword"
  2292. };
  2293. BasicAuthButton.prototype.applyPassword = function() {
  2294. var elem, password, username;
  2295. console.log("applying password");
  2296. username = $(".input_username").val();
  2297. password = $(".input_password").val();
  2298. window.authorizations.add(this.model.type, new PasswordAuthorization("basic", username, password));
  2299. window.swaggerUi.load();
  2300. return elem = $('#basic_auth_container').hide();
  2301. };
  2302. BasicAuthButton.prototype.togglePasswordContainer = function() {
  2303. var elem;
  2304. if ($('#basic_auth_container').length > 0) {
  2305. elem = $('#basic_auth_container').show();
  2306. if (elem.is(':visible')) {
  2307. return elem.slideUp();
  2308. } else {
  2309. $('.auth_container').hide();
  2310. return elem.show();
  2311. }
  2312. }
  2313. };
  2314. BasicAuthButton.prototype.template = function() {
  2315. return Handlebars.templates.basic_auth_button_view;
  2316. };
  2317. return BasicAuthButton;
  2318. })(Backbone.View);
  2319. }).call(this);