No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 

2269 líneas
87 KiB

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