swagger-ui.js 108 KB

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