2 * Copyright 2016 2015-2016 ZTE, Inc. and others. All rights reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Author: Zhaoxing Meng
17 * email: meng.zhaoxing1@zte.com.cn
20 * 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
22 * @link http://swagger.io
27 // Helper function for vertically aligning DOM elements
28 // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
29 $.fn.vAlign = function() {
30 return this.each(function(i){
31 var ah = $(this).height();
32 var ph = $(this).parent().height();
33 var mh = (ph - ah) / 2;
34 $(this).css('margin-top', mh);
38 $.fn.stretchFormtasticInputWidthToParent = function() {
39 return this.each(function(i){
40 var p_width = $(this).closest("form").innerWidth();
41 var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
42 var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
43 $(this).css('width', p_width - p_padding - this_padding);
47 $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
49 // Vertically center these paragraphs
50 // Parent may need a min-height for this to work..
51 $('ul.downplayed li div.content p').vAlign();
53 // When a sandbox form is submitted..
54 $("form.sandbox").submit(function(){
56 var error_free = true;
58 // Cycle through the forms required inputs
59 $(this).find("input.required").each(function() {
61 // Remove any existing error styles from the input
62 $(this).removeClass('error');
64 // Tack the error style on if the input is empty..
65 if ($(this).val() == '') {
66 $(this).addClass('error');
78 function clippyCopiedCallback(a) {
79 $('#api_key_copied').fadeIn().delay(1000).fadeOut();
81 // var b = $("#clippy_tooltip_" + a);
82 // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
83 // b.attr("title", "copy to clipboard")
88 // Logging function that accounts for browsers that don't have window.console
90 log.history = log.history || [];
91 log.history.push(arguments);
93 console.log( Array.prototype.slice.call(arguments)[0] );
97 // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
98 if (Function.prototype.bind && console && typeof console.log == "object") {
100 "log","info","warn","error","assert","dir","clear","profile","profileEnd"
101 ].forEach(function (method) {
102 console[method] = this.bind(console[method], console);
103 }, Function.prototype.call);
108 shebang: function() {
110 // If shebang has an operation nickname in it..
111 // e.g. /docs/#!/words/get_search
112 var fragments = $.param.fragment().split('/');
113 fragments.shift(); // get rid of the bang
115 switch (fragments.length) {
117 // Expand all operations for the resource and scroll to it
118 var dom_id = 'resource_' + fragments[0];
120 Docs.expandEndpointListForResource(fragments[0]);
121 $("#"+dom_id).slideto({highlight: false});
124 // Refer to the endpoint DOM element, e.g. #words_get_search
127 Docs.expandEndpointListForResource(fragments[0]);
128 $("#"+dom_id).slideto({highlight: false});
131 var li_dom_id = fragments.join('_');
132 var li_content_dom_id = li_dom_id + "_content";
135 Docs.expandOperation($('#'+li_content_dom_id));
136 $('#'+li_dom_id).slideto({highlight: false});
142 toggleEndpointListForResource: function(resource) {
143 var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
144 if (elem.is(':visible')) {
145 Docs.collapseEndpointListForResource(resource);
147 Docs.expandEndpointListForResource(resource);
152 expandEndpointListForResource: function(resource) {
153 var resource = Docs.escapeResourceName(resource);
154 if (resource == '') {
155 $('.resource ul.endpoints').slideDown();
159 $('li#resource_' + resource).addClass('active');
161 var elem = $('li#resource_' + resource + ' ul.endpoints');
165 // Collapse resource and mark as explicitly closed
166 collapseEndpointListForResource: function(resource) {
167 var resource = Docs.escapeResourceName(resource);
168 if (resource == '') {
169 $('.resource ul.endpoints').slideUp();
173 $('li#resource_' + resource).removeClass('active');
175 var elem = $('li#resource_' + resource + ' ul.endpoints');
179 expandOperationsForResource: function(resource) {
180 // Make sure the resource container is open..
181 Docs.expandEndpointListForResource(resource);
183 if (resource == '') {
184 $('.resource ul.endpoints li.operation div.content').slideDown();
188 $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
189 Docs.expandOperation($(this));
193 collapseOperationsForResource: function(resource) {
194 // Make sure the resource container is open..
195 Docs.expandEndpointListForResource(resource);
197 if (resource == '') {
198 $('.resource ul.endpoints li.operation div.content').slideUp();
202 $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
203 Docs.collapseOperation($(this));
207 escapeResourceName: function(resource) {
208 return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
211 expandOperation: function(elem) {
215 collapseOperation: function(elem) {
220 this["Handlebars"] = this["Handlebars"] || {};
221 this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
222 this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
223 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
224 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'>"
225 + 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)))
226 + "</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";
229 __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; },
230 __hasProp = {}.hasOwnProperty;
232 SwaggerUi = (function(_super) {
233 __extends(SwaggerUi, _super);
235 function SwaggerUi() {
236 return SwaggerUi.__super__.constructor.apply(this, arguments);
239 SwaggerUi.prototype.dom_id = "swagger_ui";
241 SwaggerUi.prototype.options = null;
243 SwaggerUi.prototype.api = null;
245 SwaggerUi.prototype.headerView = null;
247 SwaggerUi.prototype.mainView = null;
249 SwaggerUi.prototype.initialize = function(options) {
250 if (options == null) {
253 if (options.dom_id != null) {
254 this.dom_id = options.dom_id;
255 delete options.dom_id;
257 if (options.supportedSubmitMethods == null) {
258 options.supportedSubmitMethods = ['get', 'put', 'post', 'delete', 'head', 'options', 'patch'];
260 if ($('#' + this.dom_id) == null) {
261 $('body').append('<div id="' + this.dom_id + '"></div>');
263 this.options = options;
264 this.options.success = (function(_this) {
266 return _this.render();
269 this.options.progress = (function(_this) {
271 return _this.showMessage(d);
274 this.options.failure = (function(_this) {
276 return _this.onLoadFailure(d);
279 this.headerView = new HeaderView({
282 return this.headerView.on('update-swagger-ui', (function(_this) {
283 return function(data) {
284 return _this.updateSwaggerUi(data);
289 SwaggerUi.prototype.setOption = function(option, value) {
290 return this.options[option] = value;
293 SwaggerUi.prototype.getOption = function(option) {
294 return this.options[option];
297 SwaggerUi.prototype.updateSwaggerUi = function(data) {
298 this.options.url = data.url;
302 SwaggerUi.prototype.load = function() {
304 if ((_ref = this.mainView) != null) {
307 url = this.options.url;
308 if (url && url.indexOf("http") !== 0) {
309 url = this.buildUrl(window.location.href.toString(), url);
311 this.options.url = url;
312 this.headerView.update(url);
313 return this.api = new SwaggerClient(this.options);
316 SwaggerUi.prototype.collapseAll = function() {
317 return Docs.collapseEndpointListForResource('');
320 SwaggerUi.prototype.listAll = function() {
321 return Docs.collapseOperationsForResource('');
324 SwaggerUi.prototype.expandAll = function() {
325 return Docs.expandOperationsForResource('');
328 SwaggerUi.prototype.render = function() {
329 this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
330 this.mainView = new MainView({
332 el: $('#' + this.dom_id),
333 swaggerOptions: this.options
336 switch (this.options.docExpansion) {
344 if (this.options.onComplete) {
345 this.options.onComplete(this.api, this);
347 return setTimeout((function(_this) {
349 return Docs.shebang();
354 SwaggerUi.prototype.buildUrl = function(base, url) {
355 var endOfPath, parts;
356 if (url.indexOf("/") === 0) {
357 parts = base.split("/");
358 base = parts[0] + "//" + parts[2];
361 endOfPath = base.length;
362 if (base.indexOf("?") > -1) {
363 endOfPath = Math.min(endOfPath, base.indexOf("?"));
365 if (base.indexOf("#") > -1) {
366 endOfPath = Math.min(endOfPath, base.indexOf("#"));
368 base = base.substring(0, endOfPath);
369 if (base.indexOf("/", base.length - 1) !== -1) {
372 return base + "/" + url;
376 SwaggerUi.prototype.showMessage = function(data) {
380 $('#message-bar').removeClass('message-fail');
381 $('#message-bar').addClass('message-success');
382 return $('#message-bar').html(data);
385 SwaggerUi.prototype.onLoadFailure = function(data) {
390 $('#message-bar').removeClass('message-success');
391 $('#message-bar').addClass('message-fail');
392 val = $('#message-bar').html(data);
393 if (this.options.onFailure != null) {
394 this.options.onFailure(data);
399 SwaggerUi.prototype.renderGFM = function(data) {
403 return $('.markdown').each(function(index) {
404 return $(this).html(marked($(this).html()));
412 window.SwaggerUi = SwaggerUi;
414 this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
415 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";
417 Handlebars.registerHelper('sanitize', function(html) {
418 html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
419 return new Handlebars.SafeString(html);
422 this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
423 var stack1, buffer = "";
424 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
425 if (stack1 != null) { buffer += stack1; }
427 },"2":function(depth0,helpers,partials,data) {
428 var stack1, lambda=this.lambda, buffer = " <option value=\"";
429 stack1 = lambda(depth0, depth0);
430 if (stack1 != null) { buffer += stack1; }
432 stack1 = lambda(depth0, depth0);
433 if (stack1 != null) { buffer += stack1; }
434 return buffer + "</option>\n";
435 },"4":function(depth0,helpers,partials,data) {
436 return " <option value=\"application/json\">application/json</option>\n";
437 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
438 var stack1, buffer = "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
439 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});
440 if (stack1 != null) { buffer += stack1; }
441 return buffer + "</select>\n";
444 __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; },
445 __hasProp = {}.hasOwnProperty;
447 ApiKeyButton = (function(_super) {
448 __extends(ApiKeyButton, _super);
450 function ApiKeyButton() {
451 return ApiKeyButton.__super__.constructor.apply(this, arguments);
454 ApiKeyButton.prototype.initialize = function() {};
456 ApiKeyButton.prototype.render = function() {
458 template = this.template();
459 $(this.el).html(template(this.model));
463 ApiKeyButton.prototype.events = {
464 "click #apikey_button": "toggleApiKeyContainer",
465 "click #apply_api_key": "applyApiKey"
468 ApiKeyButton.prototype.applyApiKey = function() {
470 window.authorizations.add(this.model.name, new ApiKeyAuthorization(this.model.name, $("#input_apiKey_entry").val(), this.model["in"]));
471 window.swaggerUi.load();
472 return elem = $('#apikey_container').show();
475 ApiKeyButton.prototype.toggleApiKeyContainer = function() {
477 if ($('#apikey_container').length > 0) {
478 elem = $('#apikey_container').first();
479 if (elem.is(':visible')) {
482 $('.auth_container').hide();
488 ApiKeyButton.prototype.template = function() {
489 return Handlebars.templates.apikey_button_view;
496 this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
497 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">"
498 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
499 + "</div>\n <div class=\"info_description markdown\">";
500 stack1 = lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.description : stack1), depth0);
501 if (stack1 != null) { buffer += stack1; }
502 buffer += "</div>\n ";
503 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});
504 if (stack1 != null) { buffer += stack1; }
506 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});
507 if (stack1 != null) { buffer += stack1; }
509 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});
510 if (stack1 != null) { buffer += stack1; }
512 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});
513 if (stack1 != null) { buffer += stack1; }
515 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});
516 if (stack1 != null) { buffer += stack1; }
517 return buffer + "\n";
518 },"2":function(depth0,helpers,partials,data) {
519 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
520 return "<div class=\"info_tos\"><a href=\""
521 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), depth0))
522 + "\">Terms of service</a></div>";
523 },"4":function(depth0,helpers,partials,data) {
524 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
525 return "<div class='info_name'>Created by "
526 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), depth0))
528 },"6":function(depth0,helpers,partials,data) {
529 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
530 return "<div class='info_url'>See more at <a href=\""
531 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
533 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
535 },"8":function(depth0,helpers,partials,data) {
536 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
537 return "<div class='info_email'><a href=\"mailto:"
538 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), depth0))
540 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
541 + "\">Contact the developer</a></div>";
542 },"10":function(depth0,helpers,partials,data) {
543 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
544 return "<div class='info_license'><a href='"
545 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.url : stack1), depth0))
547 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.name : stack1), depth0))
549 },"12":function(depth0,helpers,partials,data) {
550 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
551 return " , <span style=\"font-variant: small-caps\">api version</span>: "
552 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), depth0))
554 },"14":function(depth0,helpers,partials,data) {
555 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
556 return " <span style=\"float:right\"><a href=\""
557 + 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)))
559 + 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)))
560 + "\"><img id=\"validator\" src=\""
561 + 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)))
563 + 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)))
564 + "\"></a>\n </span>\n";
565 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
566 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n";
567 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
568 if (stack1 != null) { buffer += stack1; }
569 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>: "
570 + 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)))
572 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});
573 if (stack1 != null) { buffer += stack1; }
575 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.validatorUrl : depth0), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data});
576 if (stack1 != null) { buffer += stack1; }
577 return buffer + " </h4>\n </div>\n</div>\n";
580 __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; },
581 __hasProp = {}.hasOwnProperty;
583 BasicAuthButton = (function(_super) {
584 __extends(BasicAuthButton, _super);
586 function BasicAuthButton() {
587 return BasicAuthButton.__super__.constructor.apply(this, arguments);
590 BasicAuthButton.prototype.initialize = function() {};
592 BasicAuthButton.prototype.render = function() {
594 template = this.template();
595 $(this.el).html(template(this.model));
599 BasicAuthButton.prototype.events = {
600 "click #basic_auth_button": "togglePasswordContainer",
601 "click #apply_basic_auth": "applyPassword"
604 BasicAuthButton.prototype.applyPassword = function() {
605 var elem, password, username;
606 username = $(".input_username").val();
607 password = $(".input_password").val();
608 window.authorizations.add(this.model.type, new PasswordAuthorization("basic", username, password));
609 window.swaggerUi.load();
610 return elem = $('#basic_auth_container').hide();
613 BasicAuthButton.prototype.togglePasswordContainer = function() {
615 if ($('#basic_auth_container').length > 0) {
616 elem = $('#basic_auth_container').show();
617 if (elem.is(':visible')) {
618 return elem.slideUp();
620 $('.auth_container').hide();
626 BasicAuthButton.prototype.template = function() {
627 return Handlebars.templates.basic_auth_button_view;
630 return BasicAuthButton;
634 this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
636 },"3":function(depth0,helpers,partials,data) {
637 return " <h4>Warning: Deprecated</h4>\n";
638 },"5":function(depth0,helpers,partials,data) {
639 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4>Implementation Notes</h4>\n <p class=\"markdown\">";
640 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));
641 if (stack1 != null) { buffer += stack1; }
642 return buffer + "</p>\n";
643 },"7":function(depth0,helpers,partials,data) {
644 return " <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
645 },"9":function(depth0,helpers,partials,data) {
646 var stack1, buffer = " <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n";
647 stack1 = helpers.each.call(depth0, depth0, {"name":"each","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data});
648 if (stack1 != null) { buffer += stack1; }
649 return buffer + " </div>\n";
650 },"10":function(depth0,helpers,partials,data) {
651 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div title='";
652 stack1 = lambda((depth0 != null ? depth0.description : depth0), depth0);
653 if (stack1 != null) { buffer += stack1; }
655 + escapeExpression(lambda((depth0 != null ? depth0.scope : depth0), depth0))
657 },"12":function(depth0,helpers,partials,data) {
659 },"14":function(depth0,helpers,partials,data) {
660 return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n";
661 },"16":function(depth0,helpers,partials,data) {
662 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
663 return " <h4>Response Class (Status "
664 + 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)))
665 + ")</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n";
666 },"18":function(depth0,helpers,partials,data) {
667 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";
668 },"20":function(depth0,helpers,partials,data) {
669 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";
670 },"22":function(depth0,helpers,partials,data) {
672 },"24":function(depth0,helpers,partials,data) {
673 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";
674 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
675 var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='"
676 + 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)))
678 + 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)))
680 + 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)))
681 + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/"
682 + 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)))
684 + 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)))
685 + "' class=\"toggleOperation\">"
686 + 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)))
687 + "</a>\n </span>\n <span class='path'>\n <a href='#!/"
688 + 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)))
690 + 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)))
691 + "' class=\"toggleOperation ";
692 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.deprecated : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
693 if (stack1 != null) { buffer += stack1; }
695 + 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)))
696 + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/"
697 + 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)))
699 + 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)))
700 + "' class=\"toggleOperation\">";
701 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));
702 if (stack1 != null) { buffer += stack1; }
703 buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='"
704 + 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)))
706 + 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)))
707 + "_content' style='display:none'>\n";
708 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.deprecated : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data});
709 if (stack1 != null) { buffer += stack1; }
710 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.description : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.noop,"data":data});
711 if (stack1 != null) { buffer += stack1; }
712 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));
713 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
714 if (stack1 != null) { buffer += stack1; }
716 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.oauth : depth0), {"name":"each","hash":{},"fn":this.program(9, data),"inverse":this.noop,"data":data});
717 if (stack1 != null) { buffer += stack1; }
719 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));
720 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
721 if (stack1 != null) { buffer += stack1; }
723 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));
724 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
725 if (stack1 != null) { buffer += stack1; }
726 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.type : depth0), {"name":"if","hash":{},"fn":this.program(16, data),"inverse":this.noop,"data":data});
727 if (stack1 != null) { buffer += stack1; }
728 buffer += " <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n";
729 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.parameters : depth0), {"name":"if","hash":{},"fn":this.program(18, data),"inverse":this.noop,"data":data});
730 if (stack1 != null) { buffer += stack1; }
731 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.responseMessages : depth0), {"name":"if","hash":{},"fn":this.program(20, data),"inverse":this.noop,"data":data});
732 if (stack1 != null) { buffer += stack1; }
733 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});
734 if (stack1 != null) { buffer += stack1; }
735 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";
738 __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; },
739 __hasProp = {}.hasOwnProperty;
741 ContentTypeView = (function(_super) {
742 __extends(ContentTypeView, _super);
744 function ContentTypeView() {
745 return ContentTypeView.__super__.constructor.apply(this, arguments);
748 ContentTypeView.prototype.initialize = function() {};
750 ContentTypeView.prototype.render = function() {
752 template = this.template();
753 $(this.el).html(template(this.model));
754 $('label[for=contentType]', $(this.el)).text('Response Content Type');
758 ContentTypeView.prototype.template = function() {
759 return Handlebars.templates.content_type;
762 return ContentTypeView;
766 this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
767 var stack1, buffer = "";
768 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});
769 if (stack1 != null) { buffer += stack1; }
771 },"2":function(depth0,helpers,partials,data) {
772 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
773 return " <input type=\"file\" name='"
774 + 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)))
775 + "'/>\n <div class=\"parameter-content-type\" />\n";
776 },"4":function(depth0,helpers,partials,data) {
777 var stack1, buffer = "";
778 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});
779 if (stack1 != null) { buffer += stack1; }
781 },"5":function(depth0,helpers,partials,data) {
782 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
783 return " <textarea class='body-textarea' name='"
784 + 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)))
786 + 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)))
787 + "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
788 },"7":function(depth0,helpers,partials,data) {
789 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
790 return " <textarea class='body-textarea' name='"
791 + 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)))
792 + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
793 },"9":function(depth0,helpers,partials,data) {
794 var stack1, buffer = "";
795 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});
796 if (stack1 != null) { buffer += stack1; }
798 },"10":function(depth0,helpers,partials,data) {
799 var stack1, buffer = "";
800 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});
801 if (stack1 != null) { buffer += stack1; }
803 },"11":function(depth0,helpers,partials,data) {
804 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
805 return " <input class='parameter' minlength='0' name='"
806 + 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)))
807 + "' placeholder='' type='text' value='"
808 + 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)))
810 },"13":function(depth0,helpers,partials,data) {
811 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
812 return " <input class='parameter' minlength='0' name='"
813 + 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)))
814 + "' placeholder='' type='text' value=''/>\n";
815 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
816 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
817 + 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)))
819 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});
820 if (stack1 != null) { buffer += stack1; }
821 buffer += "\n</td>\n<td class=\"markdown\">";
822 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));
823 if (stack1 != null) { buffer += stack1; }
824 buffer += "</td>\n<td>";
825 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));
826 if (stack1 != null) { buffer += stack1; }
827 return buffer + "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
830 __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; },
831 __hasProp = {}.hasOwnProperty;
833 HeaderView = (function(_super) {
834 __extends(HeaderView, _super);
836 function HeaderView() {
837 return HeaderView.__super__.constructor.apply(this, arguments);
840 HeaderView.prototype.events = {
841 'click #show-pet-store-icon': 'showPetStore',
842 'click #show-wordnik-dev-icon': 'showWordnikDev',
843 'click #explore': 'showCustom',
844 'keyup #input_baseUrl': 'showCustomOnKeyup',
845 'keyup #input_apiKey': 'showCustomOnKeyup'
848 HeaderView.prototype.initialize = function() {};
850 HeaderView.prototype.showPetStore = function(e) {
851 return this.trigger('update-swagger-ui', {
852 url: "http://petstore.swagger.wordnik.com/api/api-docs"
856 HeaderView.prototype.showWordnikDev = function(e) {
857 return this.trigger('update-swagger-ui', {
858 url: "http://api.wordnik.com/v4/resources.json"
862 HeaderView.prototype.showCustomOnKeyup = function(e) {
863 if (e.keyCode === 13) {
864 return this.showCustom();
868 HeaderView.prototype.showCustom = function(e) {
872 return this.trigger('update-swagger-ui', {
873 url: $('#input_baseUrl').val(),
874 apiKey: $('#input_apiKey').val()
878 HeaderView.prototype.update = function(url, apiKey, trigger) {
879 if (trigger == null) {
882 $('#input_baseUrl').val(url);
884 return this.trigger('update-swagger-ui', {
894 this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
895 return " multiple='multiple'";
896 },"3":function(depth0,helpers,partials,data) {
898 },"5":function(depth0,helpers,partials,data) {
899 var stack1, buffer = "";
900 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});
901 if (stack1 != null) { buffer += stack1; }
903 },"6":function(depth0,helpers,partials,data) {
904 var stack1, helperMissing=helpers.helperMissing, buffer = "";
905 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}));
906 if (stack1 != null) { buffer += stack1; }
908 },"7":function(depth0,helpers,partials,data) {
909 return " <option selected=\"\" value=''></option>\n";
910 },"9":function(depth0,helpers,partials,data) {
911 var stack1, buffer = "";
912 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});
913 if (stack1 != null) { buffer += stack1; }
915 },"10":function(depth0,helpers,partials,data) {
916 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
917 return " <option selected=\"\" value='"
918 + 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)))
920 + 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)))
921 + " (default)</option>\n";
922 },"12":function(depth0,helpers,partials,data) {
923 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
924 return " <option value='"
925 + 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)))
927 + 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)))
929 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
930 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
931 + 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)))
932 + "</td>\n<td>\n <select ";
933 stack1 = ((helpers.isArray || (depth0 && depth0.isArray) || helperMissing).call(depth0, depth0, {"name":"isArray","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}));
934 if (stack1 != null) { buffer += stack1; }
935 buffer += " class='parameter' name='"
936 + 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)))
938 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});
939 if (stack1 != null) { buffer += stack1; }
940 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});
941 if (stack1 != null) { buffer += stack1; }
942 buffer += " </select>\n</td>\n<td class=\"markdown\">";
943 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));
944 if (stack1 != null) { buffer += stack1; }
945 buffer += "</td>\n<td>";
946 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));
947 if (stack1 != null) { buffer += stack1; }
948 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>";
951 __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; },
952 __hasProp = {}.hasOwnProperty;
954 MainView = (function(_super) {
957 __extends(MainView, _super);
959 function MainView() {
960 return MainView.__super__.constructor.apply(this, arguments);
964 'alpha': function(a, b) {
965 return a.path.localeCompare(b.path);
967 'method': function(a, b) {
968 return a.method.localeCompare(b.method);
972 MainView.prototype.initialize = function(opts) {
973 var auth, key, value, _ref;
977 this.model.auths = [];
978 _ref = this.model.securityDefinitions;
986 this.model.auths.push(auth);
988 if (this.model.swaggerVersion === "2.0") {
989 if ("validatorUrl" in opts.swaggerOptions) {
990 return this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
991 } else if (this.model.url.indexOf("localhost") > 0) {
992 return this.model.validatorUrl = null;
994 // return this.model.validatorUrl = "http://online.swagger.io/validator";
995 return this.model.validatorUrl = null;
1000 MainView.prototype.render = function() {
1001 var auth, button, counter, id, name, resource, resources, _i, _len, _ref;
1002 if (this.model.securityDefinitions) {
1003 for (name in this.model.securityDefinitions) {
1004 auth = this.model.securityDefinitions[name];
1005 if (auth.type === "apiKey" && $("#apikey_button").length === 0) {
1006 button = new ApiKeyButton({
1009 $('.auth_main_container').append(button);
1011 if (auth.type === "basicAuth" && $("#basic_auth_button").length === 0) {
1012 button = new BasicAuthButton({
1015 $('.auth_main_container').append(button);
1019 $(this.el).html(Handlebars.templates.main(this.model));
1022 _ref = this.model.apisArray;
1023 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1024 resource = _ref[_i];
1026 while (typeof resources[id] !== 'undefined') {
1027 id = id + "_" + counter;
1031 resources[id] = resource;
1032 this.addResource(resource, this.model.auths);
1034 $('.propWrap').hover(function() {
1035 return $('.optionsWrapper', $(this)).show();
1037 return $('.optionsWrapper', $(this)).hide();
1042 MainView.prototype.addResource = function(resource, auths) {
1044 resource.id = resource.id.replace(/\s/g, '_');
1045 resourceView = new ResourceView({
1048 id: 'resource_' + resource.id,
1049 className: 'resource',
1051 swaggerOptions: this.options.swaggerOptions
1053 return $('#resources').append(resourceView.render().el);
1056 MainView.prototype.clear = function() {
1057 return $(this.el).html('');
1064 this["Handlebars"]["templates"]["param_readonly"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
1065 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1066 return " <textarea class='body-textarea' readonly='readonly' name='"
1067 + 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)))
1069 + 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)))
1071 },"3":function(depth0,helpers,partials,data) {
1072 var stack1, buffer = "";
1073 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});
1074 if (stack1 != null) { buffer += stack1; }
1076 },"4":function(depth0,helpers,partials,data) {
1077 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1079 + 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)))
1081 },"6":function(depth0,helpers,partials,data) {
1082 return " (empty)\n";
1083 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
1084 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
1085 + 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)))
1087 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});
1088 if (stack1 != null) { buffer += stack1; }
1089 buffer += "</td>\n<td class=\"markdown\">";
1090 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));
1091 if (stack1 != null) { buffer += stack1; }
1092 buffer += "</td>\n<td>";
1093 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));
1094 if (stack1 != null) { buffer += stack1; }
1095 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
1097 this["Handlebars"]["templates"]["param_readonly_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
1098 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1099 return " <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='"
1100 + 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)))
1102 + 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)))
1104 },"3":function(depth0,helpers,partials,data) {
1105 var stack1, buffer = "";
1106 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});
1107 if (stack1 != null) { buffer += stack1; }
1109 },"4":function(depth0,helpers,partials,data) {
1110 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1112 + 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)))
1114 },"6":function(depth0,helpers,partials,data) {
1115 return " (empty)\n";
1116 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
1117 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
1118 + 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)))
1120 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});
1121 if (stack1 != null) { buffer += stack1; }
1122 buffer += "</td>\n<td class=\"markdown\">";
1123 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));
1124 if (stack1 != null) { buffer += stack1; }
1125 buffer += "</td>\n<td>";
1126 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));
1127 if (stack1 != null) { buffer += stack1; }
1128 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
1131 __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; },
1132 __hasProp = {}.hasOwnProperty;
1134 OperationView = (function(_super) {
1135 __extends(OperationView, _super);
1137 function OperationView() {
1138 return OperationView.__super__.constructor.apply(this, arguments);
1141 OperationView.prototype.invocationUrl = null;
1143 OperationView.prototype.events = {
1144 'submit .sandbox': 'submitOperation',
1145 'click .submit': 'submitOperation',
1146 'click .response_hider': 'hideResponse',
1147 'click .toggleOperation': 'toggleOperationContent',
1148 'mouseenter .api-ic': 'mouseEnter',
1149 'mouseout .api-ic': 'mouseExit'
1152 OperationView.prototype.initialize = function(opts) {
1156 this.auths = opts.auths;
1157 this.parentId = this.model.parentId;
1158 this.nickname = this.model.nickname;
1162 OperationView.prototype.mouseEnter = function(e) {
1163 var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
1164 elem = $(this.el).find('.content');
1167 scX = $(window).scrollLeft();
1168 scY = $(window).scrollTop();
1169 scMaxX = scX + $(window).width();
1170 scMaxY = scY + $(window).height();
1172 hgh = elem.height();
1173 if (x + wd > scMaxX) {
1179 if (y + hgh > scMaxY) {
1189 return $(e.currentTarget.parentNode).find('#api_information_panel').show();
1192 OperationView.prototype.mouseExit = function(e) {
1193 return $(e.currentTarget.parentNode).find('#api_information_panel').hide();
1196 OperationView.prototype.render = function() {
1197 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;
1198 isMethodSubmissionSupported = jQuery.inArray(this.model.method, this.model.supportedSubmitMethods()) >= 0;
1199 if (!isMethodSubmissionSupported) {
1200 this.model.isReadOnly = true;
1202 this.model.description = this.model.description || this.model.notes;
1203 if (this.model.description) {
1204 this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
1206 this.model.oauth = null;
1207 modelAuths = this.model.authorizations || this.model.security;
1209 if (Array.isArray(modelAuths)) {
1210 for (_i = 0, _len = modelAuths.length; _i < _len; _i++) {
1211 auths = modelAuths[_i];
1212 for (key in auths) {
1214 for (a in this.auths) {
1215 auth = this.auths[a];
1216 if (auth.type === 'oauth2') {
1217 this.model.oauth = {};
1218 this.model.oauth.scopes = [];
1219 _ref = auth.value.scopes;
1222 scopeIndex = auths[key].indexOf(k);
1223 if (scopeIndex >= 0) {
1228 this.model.oauth.scopes.push(o);
1236 for (k in modelAuths) {
1238 if (k === "oauth2") {
1239 if (this.model.oauth === null) {
1240 this.model.oauth = {};
1242 if (this.model.oauth.scopes === void 0) {
1243 this.model.oauth.scopes = [];
1245 for (_j = 0, _len1 = v.length; _j < _len1; _j++) {
1247 this.model.oauth.scopes.push(o);
1253 if (typeof this.model.responses !== 'undefined') {
1254 this.model.responseMessages = [];
1255 _ref1 = this.model.responses;
1256 for (code in _ref1) {
1257 value = _ref1[code];
1259 schemaObj = this.model.responses[code].schema;
1260 if (schemaObj && schemaObj['$ref']) {
1261 schema = schemaObj['$ref'];
1262 if (schema.indexOf('#/definitions/') === 0) {
1263 schema = schema.substring('#/definitions/'.length);
1266 this.model.responseMessages.push({
1268 message: value.description,
1269 responseModel: schema
1273 if (typeof this.model.responseMessages === 'undefined') {
1274 this.model.responseMessages = [];
1276 signatureModel = null;
1277 if (this.model.successResponse) {
1278 successResponse = this.model.successResponse;
1279 for (key in successResponse) {
1280 value = successResponse[key];
1281 this.model.successCode = key;
1282 if (typeof value === 'object' && typeof value.createJSONSample === 'function') {
1284 sampleJSON: JSON.stringify(value.createJSONSample(), void 0, 2),
1286 signature: value.getMockSignature()
1290 } else if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
1292 sampleJSON: this.model.responseSampleJSON,
1294 signature: this.model.responseClassSignature
1297 $(this.el).html(Handlebars.templates.operation(this.model));
1298 if (signatureModel) {
1299 responseSignatureView = new SignatureView({
1300 model: signatureModel,
1303 $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
1305 this.model.responseClassSignature = 'string';
1306 $('.model-signature', $(this.el)).html(this.model.type);
1308 contentTypeModel = {
1311 contentTypeModel.consumes = this.model.consumes;
1312 contentTypeModel.produces = this.model.produces;
1313 _ref2 = this.model.parameters;
1314 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1316 type = param.type || param.dataType || '';
1317 if (typeof type === 'undefined') {
1318 schema = param.schema;
1319 if (schema && schema['$ref']) {
1320 ref = schema['$ref'];
1321 if (ref.indexOf('#/definitions/') === 0) {
1322 type = ref.substring('#/definitions/'.length);
1328 if (type && type.toLowerCase() === 'file') {
1329 if (!contentTypeModel.consumes) {
1330 contentTypeModel.consumes = 'multipart/form-data';
1335 responseContentTypeView = new ResponseContentTypeView({
1336 model: contentTypeModel
1338 $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
1339 _ref3 = this.model.parameters;
1340 for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
1342 this.addParameter(param, contentTypeModel.consumes);
1344 _ref4 = this.model.responseMessages;
1345 for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
1346 statusCode = _ref4[_m];
1347 this.addStatusCode(statusCode);
1352 OperationView.prototype.addParameter = function(param, consumes) {
1354 param.consumes = consumes;
1355 paramView = new ParameterView({
1358 readOnly: this.model.isReadOnly
1360 return $('.operation-params', $(this.el)).append(paramView.render().el);
1363 OperationView.prototype.addStatusCode = function(statusCode) {
1365 statusCodeView = new StatusCodeView({
1369 return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
1372 OperationView.prototype.submitOperation = function(e) {
1373 var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
1377 form = $('.sandbox', $(this.el));
1379 form.find("input.required").each(function() {
1380 $(this).removeClass("error");
1381 if (jQuery.trim($(this).val()) === "") {
1382 $(this).addClass("error");
1384 callback: (function(_this) {
1386 return $(_this).focus();
1390 return error_free = false;
1393 form.find("textarea.required").each(function() {
1394 $(this).removeClass("error");
1395 if (jQuery.trim($(this).val()) === "") {
1396 $(this).addClass("error");
1398 callback: (function(_this) {
1400 return $(_this).focus();
1404 return error_free = false;
1412 isFileUpload = false;
1413 _ref = form.find("input");
1414 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1416 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1417 map[o.name] = o.value;
1419 if (o.type === "file") {
1420 map[o.name] = o.files[0];
1421 isFileUpload = true;
1424 _ref1 = form.find("textarea");
1425 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
1427 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1428 map[o.name] = o.value;
1431 _ref2 = form.find("select");
1432 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1434 val = this.getSelectedValue(o);
1435 if ((val != null) && jQuery.trim(val).length > 0) {
1439 opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
1440 opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
1441 $(".response_throbber", $(this.el)).show();
1443 return this.handleFileUpload(map, form);
1445 return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
1450 OperationView.prototype.success = function(response, parent) {
1451 return parent.showCompleteStatus(response);
1454 OperationView.prototype.handleFileUpload = function(map, form) {
1455 var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
1456 _ref = form.serializeArray();
1457 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1459 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
1460 map[o.name] = o.value;
1463 bodyParam = new FormData();
1465 _ref1 = this.model.parameters;
1466 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
1468 if (param.paramType === 'form' || param["in"] === 'formData') {
1469 if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
1470 bodyParam.append(param.name, map[param.name]);
1475 _ref2 = this.model.parameters;
1476 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
1478 if (param.paramType === 'header') {
1479 headerParams[param.name] = map[param.name];
1482 _ref3 = form.find('input[type~="file"]');
1483 for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
1485 if (typeof el.files[0] !== 'undefined') {
1486 bodyParam.append($(el).attr('name'), el.files[0]);
1490 this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), delete headerParams['Content-Type'], this.model.urlify(map, false)) : this.model.urlify(map, true);
1491 $(".request_url", $(this.el)).html("<pre></pre>");
1492 $(".request_url pre", $(this.el)).text(this.invocationUrl);
1494 type: this.model.method,
1495 url: this.invocationUrl,
1496 headers: headerParams,
1501 error: (function(_this) {
1502 return function(data, textStatus, error) {
1503 return _this.showErrorStatus(_this.wrap(data), _this);
1506 success: (function(_this) {
1507 return function(data) {
1508 return _this.showResponse(data, _this);
1511 complete: (function(_this) {
1512 return function(data) {
1513 return _this.showCompleteStatus(_this.wrap(data), _this);
1517 if (window.authorizations) {
1518 window.authorizations.apply(obj);
1521 obj.data.append("fake", "true");
1527 OperationView.prototype.wrap = function(data) {
1528 var h, headerArray, headers, i, o, _i, _len;
1530 headerArray = data.getAllResponseHeaders().split("\r");
1531 for (_i = 0, _len = headerArray.length; _i < _len; _i++) {
1532 i = headerArray[_i];
1533 h = i.match(/^([^:]*?):(.*)$/);
1538 if (h[0] !== void 0 && h[1] !== void 0) {
1539 headers[h[0].trim()] = h[1].trim();
1544 o.content.data = data.responseText;
1545 o.headers = headers;
1547 o.request.url = this.invocationUrl;
1548 o.status = data.status;
1552 OperationView.prototype.getSelectedValue = function(select) {
1553 var opt, options, _i, _len, _ref;
1554 if (!select.multiple) {
1555 return select.value;
1558 _ref = select.options;
1559 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1562 options.push(opt.value);
1565 if (options.length > 0) {
1573 OperationView.prototype.hideResponse = function(e) {
1577 $(".response", $(this.el)).slideUp();
1578 return $(".response_hider", $(this.el)).fadeOut();
1581 OperationView.prototype.showResponse = function(response) {
1583 prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
1584 return $(".response_body", $(this.el)).html(escape(prettyJson));
1587 OperationView.prototype.showErrorStatus = function(data, parent) {
1588 return parent.showStatus(data);
1591 OperationView.prototype.showCompleteStatus = function(data, parent) {
1592 return parent.showStatus(data);
1595 OperationView.prototype.formatXml = function(xml) {
1596 var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
1597 reg = /(>)(<)(\/*)/g;
1598 wsexp = /[ ]*(.*)[ ]+\n/g;
1599 contexp = /(<.+>)(.+\n)/g;
1600 xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
1603 lines = xml.split('\n');
1607 'single->single': 0,
1608 'single->closing': -1,
1609 'single->opening': 0,
1611 'closing->single': 0,
1612 'closing->closing': -1,
1613 'closing->opening': 0,
1614 'closing->other': 0,
1615 'opening->single': 1,
1616 'opening->closing': 0,
1617 'opening->opening': 1,
1618 'opening->other': 1,
1620 'other->closing': -1,
1621 'other->opening': 0,
1624 _fn = function(ln) {
1625 var fromTo, j, key, padding, type, types, value;
1627 single: Boolean(ln.match(/<.+\/>/)),
1628 closing: Boolean(ln.match(/<\/.+>/)),
1629 opening: Boolean(ln.match(/<[^!?].*>/))
1631 type = ((function() {
1634 for (key in types) {
1642 type = type === void 0 ? 'other' : type;
1643 fromTo = lastType + '->' + type;
1646 indent += transitions[fromTo];
1647 padding = ((function() {
1648 var _j, _ref, _results;
1650 for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
1655 if (fromTo === 'opening->closing') {
1656 return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
1658 return formatted += padding + ln + '\n';
1661 for (_i = 0, _len = lines.length; _i < _len; _i++) {
1668 OperationView.prototype.showStatus = function(response) {
1669 var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url;
1670 if (response.content === void 0) {
1671 content = response.data;
1674 content = response.content.data;
1675 url = response.request.url;
1677 headers = response.headers;
1680 contentType = headers["Content-Type"] || headers["content-type"];
1682 contentType = contentType.split(";")[0].trim();
1685 $(".response_body", $(this.el)).removeClass('json');
1686 $(".response_body", $(this.el)).removeClass('xml');
1688 code = $('<code />').text("no content");
1689 pre = $('<pre class="json" />').append(code);
1690 } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
1693 json = JSON.stringify(JSON.parse(content), null, " ");
1696 json = "can't parse JSON. Raw result:\n\n" + content;
1698 code = $('<code />').text(json);
1699 pre = $('<pre class="json" />').append(code);
1700 } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
1701 code = $('<code />').text(this.formatXml(content));
1702 pre = $('<pre class="xml" />').append(code);
1703 } else if (contentType === "text/html") {
1704 code = $('<code />').html(_.escape(content));
1705 pre = $('<pre class="xml" />').append(code);
1706 } else if (/^image\//.test(contentType)) {
1707 pre = $('<img>').attr('src', url);
1709 code = $('<code />').text(content);
1710 pre = $('<pre class="json" />').append(code);
1712 response_body = pre;
1713 $(".request_url", $(this.el)).html("<pre></pre>");
1714 $(".request_url pre", $(this.el)).text(url);
1715 $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
1716 $(".response_body", $(this.el)).html(response_body);
1717 $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
1718 $(".response", $(this.el)).slideDown();
1719 $(".response_hider", $(this.el)).show();
1720 $(".response_throbber", $(this.el)).hide();
1721 response_body_el = $('.response_body', $(this.el))[0];
1722 opts = this.options.swaggerOptions;
1723 if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
1724 return response_body_el;
1726 return hljs.highlightBlock(response_body_el);
1730 OperationView.prototype.toggleOperationContent = function() {
1732 elem = $('#' + Docs.escapeResourceName(this.parentId + "_" + this.nickname + "_content"));
1733 if (elem.is(':visible')) {
1734 return Docs.collapseOperation(elem);
1736 return Docs.expandOperation(elem);
1740 return OperationView;
1744 var ParameterContentTypeView,
1745 __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; },
1746 __hasProp = {}.hasOwnProperty;
1748 ParameterContentTypeView = (function(_super) {
1749 __extends(ParameterContentTypeView, _super);
1751 function ParameterContentTypeView() {
1752 return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
1755 ParameterContentTypeView.prototype.initialize = function() {};
1757 ParameterContentTypeView.prototype.render = function() {
1759 template = this.template();
1760 $(this.el).html(template(this.model));
1761 $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
1765 ParameterContentTypeView.prototype.template = function() {
1766 return Handlebars.templates.parameter_content_type;
1769 return ParameterContentTypeView;
1773 this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
1774 var stack1, buffer = "";
1775 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});
1776 if (stack1 != null) { buffer += stack1; }
1778 },"2":function(depth0,helpers,partials,data) {
1779 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1780 return " <input type=\"file\" name='"
1781 + 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)))
1783 },"4":function(depth0,helpers,partials,data) {
1784 var stack1, buffer = "";
1785 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});
1786 if (stack1 != null) { buffer += stack1; }
1788 },"5":function(depth0,helpers,partials,data) {
1789 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1790 return " <textarea class='body-textarea required' placeholder='(required)' name='"
1791 + 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)))
1793 + 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)))
1794 + "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
1795 },"7":function(depth0,helpers,partials,data) {
1796 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1797 return " <textarea class='body-textarea required' placeholder='(required)' name='"
1798 + 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)))
1799 + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
1800 },"9":function(depth0,helpers,partials,data) {
1801 var stack1, buffer = "";
1802 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});
1803 if (stack1 != null) { buffer += stack1; }
1805 },"10":function(depth0,helpers,partials,data) {
1806 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1807 return " <input class='parameter' class='required' type='file' name='"
1808 + 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)))
1810 },"12":function(depth0,helpers,partials,data) {
1811 var stack1, buffer = "";
1812 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});
1813 if (stack1 != null) { buffer += stack1; }
1815 },"13":function(depth0,helpers,partials,data) {
1816 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1817 return " <input class='parameter required' minlength='1' name='"
1818 + 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)))
1819 + "' placeholder='(required)' type='text' value='"
1820 + 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)))
1822 },"15":function(depth0,helpers,partials,data) {
1823 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
1824 return " <input class='parameter required' minlength='1' name='"
1825 + 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)))
1826 + "' placeholder='(required)' type='text' value=''/>\n";
1827 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
1828 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
1829 + 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)))
1831 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});
1832 if (stack1 != null) { buffer += stack1; }
1833 buffer += "</td>\n<td>\n <strong><span class=\"markdown\">";
1834 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));
1835 if (stack1 != null) { buffer += stack1; }
1836 buffer += "</span></strong>\n</td>\n<td>";
1837 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));
1838 if (stack1 != null) { buffer += stack1; }
1839 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
1841 this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
1842 var stack1, buffer = "";
1843 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
1844 if (stack1 != null) { buffer += stack1; }
1846 },"2":function(depth0,helpers,partials,data) {
1847 var stack1, lambda=this.lambda, buffer = " <option value=\"";
1848 stack1 = lambda(depth0, depth0);
1849 if (stack1 != null) { buffer += stack1; }
1851 stack1 = lambda(depth0, depth0);
1852 if (stack1 != null) { buffer += stack1; }
1853 return buffer + "</option>\n";
1854 },"4":function(depth0,helpers,partials,data) {
1855 return " <option value=\"application/json\">application/json</option>\n";
1856 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
1857 var stack1, buffer = "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
1858 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});
1859 if (stack1 != null) { buffer += stack1; }
1860 return buffer + "</select>\n";
1863 __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; },
1864 __hasProp = {}.hasOwnProperty;
1866 ParameterView = (function(_super) {
1867 __extends(ParameterView, _super);
1869 function ParameterView() {
1870 return ParameterView.__super__.constructor.apply(this, arguments);
1873 ParameterView.prototype.initialize = function() {
1874 return Handlebars.registerHelper('isArray', function(param, opts) {
1875 if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
1876 return opts.fn(this);
1878 return opts.inverse(this);
1883 ParameterView.prototype.render = function() {
1884 var contentTypeModel, isParam, parameterContentTypeView, ref, responseContentTypeView, schema, signatureModel, signatureView, template, type;
1885 type = this.model.type || this.model.dataType;
1886 if (typeof type === 'undefined') {
1887 schema = this.model.schema;
1888 if (schema && schema['$ref']) {
1889 ref = schema['$ref'];
1890 if (ref.indexOf('#/definitions/') === 0) {
1891 type = ref.substring('#/definitions/'.length);
1897 this.model.type = type;
1898 this.model.paramType = this.model["in"] || this.model.paramType;
1899 if (this.model.paramType === 'body' || this.model["in"] === 'body') {
1900 this.model.isBody = true;
1902 if (type && type.toLowerCase() === 'file') {
1903 this.model.isFile = true;
1905 this.model["default"] = this.model["default"] || this.model.defaultValue;
1906 if (this.model.allowableValues) {
1907 this.model.isList = true;
1909 template = this.template();
1910 $(this.el).html(template(this.model));
1912 sampleJSON: this.model.sampleJSON,
1914 signature: this.model.signature
1916 if (this.model.sampleJSON) {
1917 signatureView = new SignatureView({
1918 model: signatureModel,
1921 $('.model-signature', $(this.el)).append(signatureView.render().el);
1923 $('.model-signature', $(this.el)).html(this.model.signature);
1926 if (this.model.isBody) {
1929 contentTypeModel = {
1932 contentTypeModel.consumes = this.model.consumes;
1934 parameterContentTypeView = new ParameterContentTypeView({
1935 model: contentTypeModel
1937 $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
1939 responseContentTypeView = new ResponseContentTypeView({
1940 model: contentTypeModel
1942 $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
1947 ParameterView.prototype.template = function() {
1948 if (this.model.isList) {
1949 return Handlebars.templates.param_list;
1951 if (this.options.readOnly) {
1952 if (this.model.required) {
1953 return Handlebars.templates.param_readonly_required;
1955 return Handlebars.templates.param_readonly;
1958 if (this.model.required) {
1959 return Handlebars.templates.param_required;
1961 return Handlebars.templates.param;
1967 return ParameterView;
1972 __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; },
1973 __hasProp = {}.hasOwnProperty;
1975 ResourceView = (function(_super) {
1976 __extends(ResourceView, _super);
1978 function ResourceView() {
1979 return ResourceView.__super__.constructor.apply(this, arguments);
1982 ResourceView.prototype.initialize = function(opts) {
1986 this.auths = opts.auths;
1987 if ("" === this.model.description) {
1988 this.model.description = null;
1990 if (this.model.description != null) {
1991 return this.model.summary = this.model.description;
1995 ResourceView.prototype.render = function() {
1996 var counter, id, methods, operation, _i, _len, _ref;
1998 $(this.el).html(Handlebars.templates.resource(this.model));
1999 _ref = this.model.operationsArray;
2000 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
2001 operation = _ref[_i];
2003 id = operation.nickname;
2004 while (typeof methods[id] !== 'undefined') {
2005 id = id + "_" + counter;
2008 methods[id] = operation;
2009 operation.nickname = id;
2010 operation.parentId = this.model.id;
2011 this.addOperation(operation);
2013 $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
2014 $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
2015 $('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
2019 ResourceView.prototype.addOperation = function(operation) {
2021 operation.number = this.number;
2022 operationView = new OperationView({
2025 className: 'endpoint',
2026 swaggerOptions: this.options.swaggerOptions,
2029 $('.endpoints', $(this.el)).append(operationView.render().el);
2030 return this.number++;
2033 ResourceView.prototype.callDocs = function(fnName, e) {
2035 return Docs[fnName](e.currentTarget.getAttribute('data-id'));
2038 return ResourceView;
2042 this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
2044 },"3":function(depth0,helpers,partials,data) {
2045 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
2046 return "<li>\n <a href='"
2047 + 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)))
2048 + "'>Raw</a>\n </li>";
2049 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
2050 var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "<div class='heading'>\n <h2>\n <a href='#!/"
2051 + 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)))
2052 + "' class=\"toggleEndpointList\" data-id=\""
2053 + 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)))
2055 + 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)))
2057 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));
2058 if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
2059 if (stack1 != null) { buffer += stack1; }
2060 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));
2061 if (stack1 != null) { buffer += stack1; }
2062 buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/"
2063 + 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)))
2064 + "' id='endpointListTogger_"
2065 + 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)))
2066 + "' class=\"toggleEndpointList\" data-id=\""
2067 + 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)))
2068 + "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\""
2069 + 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)))
2070 + "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=\""
2071 + 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)))
2072 + "\">\n Expand Operations\n </a>\n </li>\n ";
2073 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));
2074 if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
2075 if (stack1 != null) { buffer += stack1; }
2076 return buffer + "\n </ul>\n</div>\n<ul class='endpoints' id='"
2077 + 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)))
2078 + "_endpoint_list' style='display:none'>\n\n</ul>\n";
2080 var ResponseContentTypeView,
2081 __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; },
2082 __hasProp = {}.hasOwnProperty;
2084 ResponseContentTypeView = (function(_super) {
2085 __extends(ResponseContentTypeView, _super);
2087 function ResponseContentTypeView() {
2088 return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
2091 ResponseContentTypeView.prototype.initialize = function() {};
2093 ResponseContentTypeView.prototype.render = function() {
2095 template = this.template();
2096 $(this.el).html(template(this.model));
2097 $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
2101 ResponseContentTypeView.prototype.template = function() {
2102 return Handlebars.templates.response_content_type;
2105 return ResponseContentTypeView;
2109 this["Handlebars"]["templates"]["response_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
2110 var stack1, buffer = "";
2111 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
2112 if (stack1 != null) { buffer += stack1; }
2114 },"2":function(depth0,helpers,partials,data) {
2115 var stack1, lambda=this.lambda, buffer = " <option value=\"";
2116 stack1 = lambda(depth0, depth0);
2117 if (stack1 != null) { buffer += stack1; }
2119 stack1 = lambda(depth0, depth0);
2120 if (stack1 != null) { buffer += stack1; }
2121 return buffer + "</option>\n";
2122 },"4":function(depth0,helpers,partials,data) {
2123 return " <option value=\"application/json\">application/json</option>\n";
2124 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
2125 var stack1, buffer = "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
2126 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});
2127 if (stack1 != null) { buffer += stack1; }
2128 return buffer + "</select>\n";
2131 __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; },
2132 __hasProp = {}.hasOwnProperty;
2134 SignatureView = (function(_super) {
2135 __extends(SignatureView, _super);
2137 function SignatureView() {
2138 return SignatureView.__super__.constructor.apply(this, arguments);
2141 SignatureView.prototype.events = {
2142 'click a.description-link': 'switchToDescription',
2143 'click a.snippet-link': 'switchToSnippet',
2144 'mousedown .snippet': 'snippetToTextArea'
2147 SignatureView.prototype.initialize = function() {};
2149 SignatureView.prototype.render = function() {
2151 template = this.template();
2152 $(this.el).html(template(this.model));
2153 this.switchToSnippet();
2154 this.isParam = this.model.isParam;
2156 $('.notice', $(this.el)).text('Click to set as parameter value');
2161 SignatureView.prototype.template = function() {
2162 return Handlebars.templates.signature;
2165 SignatureView.prototype.switchToDescription = function(e) {
2169 $(".snippet", $(this.el)).hide();
2170 $(".description", $(this.el)).show();
2171 $('.description-link', $(this.el)).addClass('selected');
2172 return $('.snippet-link', $(this.el)).removeClass('selected');
2175 SignatureView.prototype.switchToSnippet = function(e) {
2179 $(".description", $(this.el)).hide();
2180 $(".snippet", $(this.el)).show();
2181 $('.snippet-link', $(this.el)).addClass('selected');
2182 return $('.description-link', $(this.el)).removeClass('selected');
2185 SignatureView.prototype.snippetToTextArea = function(e) {
2191 textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
2192 if ($.trim(textArea.val()) === '') {
2193 return textArea.val(this.model.sampleJSON);
2198 return SignatureView;
2202 this["Handlebars"]["templates"]["signature"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
2203 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 ";
2204 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));
2205 if (stack1 != null) { buffer += stack1; }
2206 return buffer + "\n </div>\n\n <div class=\"snippet\">\n <pre><code>"
2207 + 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)))
2208 + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
2211 __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; },
2212 __hasProp = {}.hasOwnProperty;
2214 StatusCodeView = (function(_super) {
2215 __extends(StatusCodeView, _super);
2217 function StatusCodeView() {
2218 return StatusCodeView.__super__.constructor.apply(this, arguments);
2221 StatusCodeView.prototype.initialize = function() {};
2223 StatusCodeView.prototype.render = function() {
2224 var responseModel, responseModelView, template;
2225 template = this.template();
2226 $(this.el).html(template(this.model));
2227 if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) {
2229 sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2),
2231 signature: swaggerUi.api.models[this.model.responseModel].getMockSignature()
2233 responseModelView = new SignatureView({
2234 model: responseModel,
2237 $('.model-signature', this.$el).append(responseModelView.render().el);
2239 $('.model-signature', this.$el).html('');
2244 StatusCodeView.prototype.template = function() {
2245 return Handlebars.templates.status_code;
2248 return StatusCodeView;
2252 this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
2253 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td width='15%' class='code'>"
2254 + 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)))
2256 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));
2257 if (stack1 != null) { buffer += stack1; }
2258 return buffer + "</td>\n<td width='50%'><span class=\"model-signature\" /></td>";