2 * Copyright (C) 2015 CMCC, Inc. and others. All rights reserved. (CMCC)
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 * 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
\r
18 * @version v2.1.8-M1
\r
19 * @link http://swagger.io
\r
20 * @license Apache 2.0
\r
24 // Helper function for vertically aligning DOM elements
\r
25 // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
\r
26 $.fn.vAlign = function() {
\r
27 return this.each(function(i){
\r
28 var ah = $(this).height();
\r
29 var ph = $(this).parent().height();
\r
30 var mh = (ph - ah) / 2;
\r
31 $(this).css('margin-top', mh);
\r
35 $.fn.stretchFormtasticInputWidthToParent = function() {
\r
36 return this.each(function(i){
\r
37 var p_width = $(this).closest("form").innerWidth();
\r
38 var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
\r
39 var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
\r
40 $(this).css('width', p_width - p_padding - this_padding);
\r
44 $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
\r
46 // Vertically center these paragraphs
\r
47 // Parent may need a min-height for this to work..
\r
48 $('ul.downplayed li div.content p').vAlign();
\r
50 // When a sandbox form is submitted..
\r
51 $("form.sandbox").submit(function(){
\r
53 var error_free = true;
\r
55 // Cycle through the forms required inputs
\r
56 $(this).find("input.required").each(function() {
\r
58 // Remove any existing error styles from the input
\r
59 $(this).removeClass('error');
\r
61 // Tack the error style on if the input is empty..
\r
62 if ($(this).val() == '') {
\r
63 $(this).addClass('error');
\r
75 function clippyCopiedCallback(a) {
\r
76 $('#api_key_copied').fadeIn().delay(1000).fadeOut();
\r
78 // var b = $("#clippy_tooltip_" + a);
\r
79 // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
\r
80 // b.attr("title", "copy to clipboard")
\r
85 // Logging function that accounts for browsers that don't have window.console
\r
87 log.history = log.history || [];
\r
88 log.history.push(arguments);
\r
90 console.log( Array.prototype.slice.call(arguments)[0] );
\r
94 // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913)
\r
95 if (Function.prototype.bind && console && typeof console.log == "object") {
\r
97 "log","info","warn","error","assert","dir","clear","profile","profileEnd"
\r
98 ].forEach(function (method) {
\r
99 console[method] = this.bind(console[method], console);
\r
100 }, Function.prototype.call);
\r
105 shebang: function() {
\r
107 // If shebang has an operation nickname in it..
\r
108 // e.g. /docs/#!/words/get_search
\r
109 var fragments = $.param.fragment().split('/');
\r
110 fragments.shift(); // get rid of the bang
\r
112 switch (fragments.length) {
\r
114 // Expand all operations for the resource and scroll to it
\r
115 var dom_id = 'resource_' + fragments[0];
\r
117 Docs.expandEndpointListForResource(fragments[0]);
\r
118 $("#"+dom_id).slideto({highlight: false});
\r
121 // Refer to the endpoint DOM element, e.g. #words_get_search
\r
124 Docs.expandEndpointListForResource(fragments[0]);
\r
125 $("#"+dom_id).slideto({highlight: false});
\r
127 // Expand operation
\r
128 var li_dom_id = fragments.join('_');
\r
129 var li_content_dom_id = li_dom_id + "_content";
\r
132 Docs.expandOperation($('#'+li_content_dom_id));
\r
133 $('#'+li_dom_id).slideto({highlight: false});
\r
139 toggleEndpointListForResource: function(resource) {
\r
140 var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
\r
141 if (elem.is(':visible')) {
\r
142 Docs.collapseEndpointListForResource(resource);
\r
144 Docs.expandEndpointListForResource(resource);
\r
149 expandEndpointListForResource: function(resource) {
\r
150 var resource = Docs.escapeResourceName(resource);
\r
151 if (resource == '') {
\r
152 $('.resource ul.endpoints').slideDown();
\r
156 $('li#resource_' + resource).addClass('active');
\r
158 var elem = $('li#resource_' + resource + ' ul.endpoints');
\r
162 // Collapse resource and mark as explicitly closed
\r
163 collapseEndpointListForResource: function(resource) {
\r
164 var resource = Docs.escapeResourceName(resource);
\r
165 if (resource == '') {
\r
166 $('.resource ul.endpoints').slideUp();
\r
170 $('li#resource_' + resource).removeClass('active');
\r
172 var elem = $('li#resource_' + resource + ' ul.endpoints');
\r
176 expandOperationsForResource: function(resource) {
\r
177 // Make sure the resource container is open..
\r
178 Docs.expandEndpointListForResource(resource);
\r
180 if (resource == '') {
\r
181 $('.resource ul.endpoints li.operation div.content').slideDown();
\r
185 $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
\r
186 Docs.expandOperation($(this));
\r
190 collapseOperationsForResource: function(resource) {
\r
191 // Make sure the resource container is open..
\r
192 Docs.expandEndpointListForResource(resource);
\r
194 if (resource == '') {
\r
195 $('.resource ul.endpoints li.operation div.content').slideUp();
\r
199 $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() {
\r
200 Docs.collapseOperation($(this));
\r
204 escapeResourceName: function(resource) {
\r
205 return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&");
\r
208 expandOperation: function(elem) {
\r
212 collapseOperation: function(elem) {
\r
217 this["Handlebars"] = this["Handlebars"] || {};
\r
218 this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
\r
219 this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
220 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
221 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'>"
\r
222 + 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)))
\r
223 + "</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";
\r
224 },"useData":true});
\r
226 __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; },
\r
227 __hasProp = {}.hasOwnProperty;
\r
229 SwaggerUi = (function(_super) {
\r
230 __extends(SwaggerUi, _super);
\r
232 function SwaggerUi() {
\r
233 return SwaggerUi.__super__.constructor.apply(this, arguments);
\r
236 SwaggerUi.prototype.dom_id = "swagger_ui";
\r
238 SwaggerUi.prototype.options = null;
\r
240 SwaggerUi.prototype.api = null;
\r
242 SwaggerUi.prototype.headerView = null;
\r
244 SwaggerUi.prototype.mainView = null;
\r
246 SwaggerUi.prototype.initialize = function(options) {
\r
247 if (options == null) {
\r
250 if (options.dom_id != null) {
\r
251 this.dom_id = options.dom_id;
\r
252 delete options.dom_id;
\r
254 if (options.supportedSubmitMethods == null) {
\r
255 options.supportedSubmitMethods = ['get', 'put', 'post', 'delete', 'head', 'options', 'patch'];
\r
257 if ($('#' + this.dom_id) == null) {
\r
258 $('body').append('<div id="' + this.dom_id + '"></div>');
\r
260 this.options = options;
\r
261 this.options.success = (function(_this) {
\r
262 return function() {
\r
263 return _this.render();
\r
266 this.options.progress = (function(_this) {
\r
267 return function(d) {
\r
268 return _this.showMessage(d);
\r
271 this.options.failure = (function(_this) {
\r
272 return function(d) {
\r
273 return _this.onLoadFailure(d);
\r
276 this.headerView = new HeaderView({
\r
279 return this.headerView.on('update-swagger-ui', (function(_this) {
\r
280 return function(data) {
\r
281 return _this.updateSwaggerUi(data);
\r
286 SwaggerUi.prototype.setOption = function(option, value) {
\r
287 return this.options[option] = value;
\r
290 SwaggerUi.prototype.getOption = function(option) {
\r
291 return this.options[option];
\r
294 SwaggerUi.prototype.updateSwaggerUi = function(data) {
\r
295 this.options.url = data.url;
\r
296 return this.load();
\r
299 SwaggerUi.prototype.load = function() {
\r
301 if ((_ref = this.mainView) != null) {
\r
304 url = this.options.url;
\r
305 if (url && url.indexOf("http") !== 0) {
\r
306 url = this.buildUrl(window.location.href.toString(), url);
\r
308 this.options.url = url;
\r
309 this.headerView.update(url);
\r
310 return this.api = new SwaggerClient(this.options);
\r
313 SwaggerUi.prototype.collapseAll = function() {
\r
314 return Docs.collapseEndpointListForResource('');
\r
317 SwaggerUi.prototype.listAll = function() {
\r
318 return Docs.collapseOperationsForResource('');
\r
321 SwaggerUi.prototype.expandAll = function() {
\r
322 return Docs.expandOperationsForResource('');
\r
325 SwaggerUi.prototype.render = function() {
\r
326 this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
\r
327 this.mainView = new MainView({
\r
329 el: $('#' + this.dom_id),
\r
330 swaggerOptions: this.options
\r
332 this.showMessage();
\r
333 switch (this.options.docExpansion) {
\r
341 if (this.options.onComplete) {
\r
342 this.options.onComplete(this.api, this);
\r
344 return setTimeout((function(_this) {
\r
345 return function() {
\r
346 return Docs.shebang();
\r
351 SwaggerUi.prototype.buildUrl = function(base, url) {
\r
352 var endOfPath, parts;
\r
353 if (url.indexOf("/") === 0) {
\r
354 parts = base.split("/");
\r
355 base = parts[0] + "//" + parts[2];
\r
358 endOfPath = base.length;
\r
359 if (base.indexOf("?") > -1) {
\r
360 endOfPath = Math.min(endOfPath, base.indexOf("?"));
\r
362 if (base.indexOf("#") > -1) {
\r
363 endOfPath = Math.min(endOfPath, base.indexOf("#"));
\r
365 base = base.substring(0, endOfPath);
\r
366 if (base.indexOf("/", base.length - 1) !== -1) {
\r
369 return base + "/" + url;
\r
373 SwaggerUi.prototype.showMessage = function(data) {
\r
374 if (data == null) {
\r
377 $('#message-bar').removeClass('message-fail');
\r
378 $('#message-bar').addClass('message-success');
\r
379 return $('#message-bar').html(data);
\r
382 SwaggerUi.prototype.onLoadFailure = function(data) {
\r
384 if (data == null) {
\r
387 $('#message-bar').removeClass('message-success');
\r
388 $('#message-bar').addClass('message-fail');
\r
389 val = $('#message-bar').html(data);
\r
390 if (this.options.onFailure != null) {
\r
391 this.options.onFailure(data);
\r
396 SwaggerUi.prototype.renderGFM = function(data) {
\r
397 if (data == null) {
\r
400 return $('.markdown').each(function(index) {
\r
401 return $(this).html(marked($(this).html()));
\r
407 })(Backbone.Router);
\r
409 window.SwaggerUi = SwaggerUi;
\r
411 this["Handlebars"]["templates"]["basic_auth_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
412 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";
\r
413 },"useData":true});
\r
414 Handlebars.registerHelper('sanitize', function(html) {
\r
415 html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
\r
416 return new Handlebars.SafeString(html);
\r
419 this["Handlebars"]["templates"]["content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
420 var stack1, buffer = "";
\r
421 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
\r
422 if (stack1 != null) { buffer += stack1; }
\r
424 },"2":function(depth0,helpers,partials,data) {
\r
425 var stack1, lambda=this.lambda, buffer = " <option value=\"";
\r
426 stack1 = lambda(depth0, depth0);
\r
427 if (stack1 != null) { buffer += stack1; }
\r
429 stack1 = lambda(depth0, depth0);
\r
430 if (stack1 != null) { buffer += stack1; }
\r
431 return buffer + "</option>\n";
\r
432 },"4":function(depth0,helpers,partials,data) {
\r
433 return " <option value=\"application/json\">application/json</option>\n";
\r
434 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
435 var stack1, buffer = "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
\r
436 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});
\r
437 if (stack1 != null) { buffer += stack1; }
\r
438 return buffer + "</select>\n";
\r
439 },"useData":true});
\r
441 __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; },
\r
442 __hasProp = {}.hasOwnProperty;
\r
444 ApiKeyButton = (function(_super) {
\r
445 __extends(ApiKeyButton, _super);
\r
447 function ApiKeyButton() {
\r
448 return ApiKeyButton.__super__.constructor.apply(this, arguments);
\r
451 ApiKeyButton.prototype.initialize = function() {};
\r
453 ApiKeyButton.prototype.render = function() {
\r
455 template = this.template();
\r
456 $(this.el).html(template(this.model));
\r
460 ApiKeyButton.prototype.events = {
\r
461 "click #apikey_button": "toggleApiKeyContainer",
\r
462 "click #apply_api_key": "applyApiKey"
\r
465 ApiKeyButton.prototype.applyApiKey = function() {
\r
467 window.authorizations.add(this.model.name, new ApiKeyAuthorization(this.model.name, $("#input_apiKey_entry").val(), this.model["in"]));
\r
468 window.swaggerUi.load();
\r
469 return elem = $('#apikey_container').show();
\r
472 ApiKeyButton.prototype.toggleApiKeyContainer = function() {
\r
474 if ($('#apikey_container').length > 0) {
\r
475 elem = $('#apikey_container').first();
\r
476 if (elem.is(':visible')) {
\r
477 return elem.hide();
\r
479 $('.auth_container').hide();
\r
480 return elem.show();
\r
485 ApiKeyButton.prototype.template = function() {
\r
486 return Handlebars.templates.apikey_button_view;
\r
489 return ApiKeyButton;
\r
493 this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
494 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div class=\"info_title\">"
\r
495 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
\r
496 + "</div>\n <div class=\"info_description markdown\">";
\r
497 stack1 = lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.description : stack1), depth0);
\r
498 if (stack1 != null) { buffer += stack1; }
\r
499 buffer += "</div>\n ";
\r
500 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});
\r
501 if (stack1 != null) { buffer += stack1; }
\r
503 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});
\r
504 if (stack1 != null) { buffer += stack1; }
\r
506 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});
\r
507 if (stack1 != null) { buffer += stack1; }
\r
509 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});
\r
510 if (stack1 != null) { buffer += stack1; }
\r
512 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});
\r
513 if (stack1 != null) { buffer += stack1; }
\r
514 return buffer + "\n";
\r
515 },"2":function(depth0,helpers,partials,data) {
\r
516 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
517 return "<div class=\"info_tos\"><a href=\""
\r
518 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), depth0))
\r
519 + "\">Terms of service</a></div>";
\r
520 },"4":function(depth0,helpers,partials,data) {
\r
521 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
522 return "<div class='info_name'>Created by "
\r
523 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), depth0))
\r
525 },"6":function(depth0,helpers,partials,data) {
\r
526 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
527 return "<div class='info_url'>See more at <a href=\""
\r
528 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
\r
530 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
\r
532 },"8":function(depth0,helpers,partials,data) {
\r
533 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
534 return "<div class='info_email'><a href=\"mailto:"
\r
535 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), depth0))
\r
537 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
\r
538 + "\">Contact the developer</a></div>";
\r
539 },"10":function(depth0,helpers,partials,data) {
\r
540 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
541 return "<div class='info_license'><a href='"
\r
542 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.url : stack1), depth0))
\r
544 + escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.name : stack1), depth0))
\r
546 },"12":function(depth0,helpers,partials,data) {
\r
547 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
\r
548 return " , <span style=\"font-variant: small-caps\">api version</span>: "
\r
549 + escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), depth0))
\r
551 },"14":function(depth0,helpers,partials,data) {
\r
552 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
553 return " <span style=\"float:right\"><a href=\""
\r
554 + 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)))
\r
556 + 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)))
\r
557 + "\"><img id=\"validator\" src=\""
\r
558 + 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)))
\r
560 + 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)))
\r
561 + "\"></a>\n </span>\n";
\r
562 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
563 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<div class='info' id='api_info'>\n";
\r
564 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.info : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
\r
565 if (stack1 != null) { buffer += stack1; }
\r
566 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>: "
\r
567 + 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)))
\r
569 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});
\r
570 if (stack1 != null) { buffer += stack1; }
\r
572 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.validatorUrl : depth0), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data});
\r
573 if (stack1 != null) { buffer += stack1; }
\r
574 return buffer + " </h4>\n </div>\n</div>\n";
\r
575 },"useData":true});
\r
576 var BasicAuthButton,
\r
577 __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; },
\r
578 __hasProp = {}.hasOwnProperty;
\r
580 BasicAuthButton = (function(_super) {
\r
581 __extends(BasicAuthButton, _super);
\r
583 function BasicAuthButton() {
\r
584 return BasicAuthButton.__super__.constructor.apply(this, arguments);
\r
587 BasicAuthButton.prototype.initialize = function() {};
\r
589 BasicAuthButton.prototype.render = function() {
\r
591 template = this.template();
\r
592 $(this.el).html(template(this.model));
\r
596 BasicAuthButton.prototype.events = {
\r
597 "click #basic_auth_button": "togglePasswordContainer",
\r
598 "click #apply_basic_auth": "applyPassword"
\r
601 BasicAuthButton.prototype.applyPassword = function() {
\r
602 var elem, password, username;
\r
603 username = $(".input_username").val();
\r
604 password = $(".input_password").val();
\r
605 window.authorizations.add(this.model.type, new PasswordAuthorization("basic", username, password));
\r
606 window.swaggerUi.load();
\r
607 return elem = $('#basic_auth_container').hide();
\r
610 BasicAuthButton.prototype.togglePasswordContainer = function() {
\r
612 if ($('#basic_auth_container').length > 0) {
\r
613 elem = $('#basic_auth_container').show();
\r
614 if (elem.is(':visible')) {
\r
615 return elem.slideUp();
\r
617 $('.auth_container').hide();
\r
618 return elem.show();
\r
623 BasicAuthButton.prototype.template = function() {
\r
624 return Handlebars.templates.basic_auth_button_view;
\r
627 return BasicAuthButton;
\r
631 this["Handlebars"]["templates"]["operation"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
632 return "deprecated";
\r
633 },"3":function(depth0,helpers,partials,data) {
\r
634 return " <h4>Warning: Deprecated</h4>\n";
\r
635 },"5":function(depth0,helpers,partials,data) {
\r
636 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, buffer = " <h4>Implementation Notes</h4>\n <p class=\"markdown\">";
\r
637 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));
\r
638 if (stack1 != null) { buffer += stack1; }
\r
639 return buffer + "</p>\n";
\r
640 },"7":function(depth0,helpers,partials,data) {
\r
641 return " <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
\r
642 },"9":function(depth0,helpers,partials,data) {
\r
643 var stack1, buffer = " <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n";
\r
644 stack1 = helpers.each.call(depth0, depth0, {"name":"each","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data});
\r
645 if (stack1 != null) { buffer += stack1; }
\r
646 return buffer + " </div>\n";
\r
647 },"10":function(depth0,helpers,partials,data) {
\r
648 var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression, buffer = " <div title='";
\r
649 stack1 = lambda((depth0 != null ? depth0.description : depth0), depth0);
\r
650 if (stack1 != null) { buffer += stack1; }
\r
651 return buffer + "'>"
\r
652 + escapeExpression(lambda((depth0 != null ? depth0.scope : depth0), depth0))
\r
654 },"12":function(depth0,helpers,partials,data) {
\r
656 },"14":function(depth0,helpers,partials,data) {
\r
657 return " <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n";
\r
658 },"16":function(depth0,helpers,partials,data) {
\r
659 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
660 return " <h4>Response Class (Status "
\r
661 + 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)))
\r
662 + ")</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n";
\r
663 },"18":function(depth0,helpers,partials,data) {
\r
664 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";
\r
665 },"20":function(depth0,helpers,partials,data) {
\r
666 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";
\r
667 },"22":function(depth0,helpers,partials,data) {
\r
669 },"24":function(depth0,helpers,partials,data) {
\r
670 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";
\r
671 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
672 var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "\n <ul class='operations' >\n <li class='"
\r
673 + 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)))
\r
674 + " operation' id='"
\r
675 + 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)))
\r
677 + 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)))
\r
678 + "'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/"
\r
679 + 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)))
\r
681 + 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)))
\r
682 + "' class=\"toggleOperation\">"
\r
683 + 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)))
\r
684 + "</a>\n </span>\n <span class='path'>\n <a href='#!/"
\r
685 + 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)))
\r
687 + 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)))
\r
688 + "' class=\"toggleOperation ";
\r
689 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.deprecated : depth0), {"name":"if","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data});
\r
690 if (stack1 != null) { buffer += stack1; }
\r
692 + 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)))
\r
693 + "</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/"
\r
694 + 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)))
\r
696 + 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)))
\r
697 + "' class=\"toggleOperation\">";
\r
698 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));
\r
699 if (stack1 != null) { buffer += stack1; }
\r
700 buffer += "</a>\n </li>\n </ul>\n </div>\n <div class='content' id='"
\r
701 + 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)))
\r
703 + 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)))
\r
704 + "_content' style='display:none'>\n";
\r
705 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.deprecated : depth0), {"name":"if","hash":{},"fn":this.program(3, data),"inverse":this.noop,"data":data});
\r
706 if (stack1 != null) { buffer += stack1; }
\r
707 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.description : depth0), {"name":"if","hash":{},"fn":this.program(5, data),"inverse":this.noop,"data":data});
\r
708 if (stack1 != null) { buffer += stack1; }
\r
709 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));
\r
710 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
\r
711 if (stack1 != null) { buffer += stack1; }
\r
713 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.oauth : depth0), {"name":"each","hash":{},"fn":this.program(9, data),"inverse":this.noop,"data":data});
\r
714 if (stack1 != null) { buffer += stack1; }
\r
716 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));
\r
717 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
\r
718 if (stack1 != null) { buffer += stack1; }
\r
720 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));
\r
721 if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
\r
722 if (stack1 != null) { buffer += stack1; }
\r
723 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.type : depth0), {"name":"if","hash":{},"fn":this.program(16, data),"inverse":this.noop,"data":data});
\r
724 if (stack1 != null) { buffer += stack1; }
\r
725 buffer += " <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n";
\r
726 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.parameters : depth0), {"name":"if","hash":{},"fn":this.program(18, data),"inverse":this.noop,"data":data});
\r
727 if (stack1 != null) { buffer += stack1; }
\r
728 stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.responseMessages : depth0), {"name":"if","hash":{},"fn":this.program(20, data),"inverse":this.noop,"data":data});
\r
729 if (stack1 != null) { buffer += stack1; }
\r
730 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});
\r
731 if (stack1 != null) { buffer += stack1; }
\r
732 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";
\r
733 },"useData":true});
\r
734 var ContentTypeView,
\r
735 __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; },
\r
736 __hasProp = {}.hasOwnProperty;
\r
738 ContentTypeView = (function(_super) {
\r
739 __extends(ContentTypeView, _super);
\r
741 function ContentTypeView() {
\r
742 return ContentTypeView.__super__.constructor.apply(this, arguments);
\r
745 ContentTypeView.prototype.initialize = function() {};
\r
747 ContentTypeView.prototype.render = function() {
\r
749 template = this.template();
\r
750 $(this.el).html(template(this.model));
\r
751 $('label[for=contentType]', $(this.el)).text('Response Content Type');
\r
755 ContentTypeView.prototype.template = function() {
\r
756 return Handlebars.templates.content_type;
\r
759 return ContentTypeView;
\r
763 this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
764 var stack1, buffer = "";
\r
765 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});
\r
766 if (stack1 != null) { buffer += stack1; }
\r
768 },"2":function(depth0,helpers,partials,data) {
\r
769 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
770 return " <input type=\"file\" name='"
\r
771 + 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)))
\r
772 + "'/>\n <div class=\"parameter-content-type\" />\n";
\r
773 },"4":function(depth0,helpers,partials,data) {
\r
774 var stack1, buffer = "";
\r
775 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});
\r
776 if (stack1 != null) { buffer += stack1; }
\r
778 },"5":function(depth0,helpers,partials,data) {
\r
779 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
780 return " <textarea class='body-textarea' name='"
\r
781 + 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)))
\r
783 + 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)))
\r
784 + "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
\r
785 },"7":function(depth0,helpers,partials,data) {
\r
786 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
787 return " <textarea class='body-textarea' name='"
\r
788 + 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)))
\r
789 + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
\r
790 },"9":function(depth0,helpers,partials,data) {
\r
791 var stack1, buffer = "";
\r
792 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});
\r
793 if (stack1 != null) { buffer += stack1; }
\r
795 },"10":function(depth0,helpers,partials,data) {
\r
796 var stack1, buffer = "";
\r
797 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});
\r
798 if (stack1 != null) { buffer += stack1; }
\r
800 },"11":function(depth0,helpers,partials,data) {
\r
801 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
802 return " <input class='parameter' minlength='0' name='"
\r
803 + 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)))
\r
804 + "' placeholder='' type='text' value='"
\r
805 + 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)))
\r
807 },"13":function(depth0,helpers,partials,data) {
\r
808 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
809 return " <input class='parameter' minlength='0' name='"
\r
810 + 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)))
\r
811 + "' placeholder='' type='text' value=''/>\n";
\r
812 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
813 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
\r
814 + 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)))
\r
815 + "</td>\n<td>\n\n";
\r
816 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});
\r
817 if (stack1 != null) { buffer += stack1; }
\r
818 buffer += "\n</td>\n<td class=\"markdown\">";
\r
819 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));
\r
820 if (stack1 != null) { buffer += stack1; }
\r
821 buffer += "</td>\n<td>";
\r
822 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));
\r
823 if (stack1 != null) { buffer += stack1; }
\r
824 return buffer + "</td>\n<td>\n <span class=\"model-signature\"></span>\n</td>\n";
\r
825 },"useData":true});
\r
827 __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; },
\r
828 __hasProp = {}.hasOwnProperty;
\r
830 HeaderView = (function(_super) {
\r
831 __extends(HeaderView, _super);
\r
833 function HeaderView() {
\r
834 return HeaderView.__super__.constructor.apply(this, arguments);
\r
837 HeaderView.prototype.events = {
\r
838 'click #show-pet-store-icon': 'showPetStore',
\r
839 'click #show-wordnik-dev-icon': 'showWordnikDev',
\r
840 'click #explore': 'showCustom',
\r
841 'keyup #input_baseUrl': 'showCustomOnKeyup',
\r
842 'keyup #input_apiKey': 'showCustomOnKeyup'
\r
845 HeaderView.prototype.initialize = function() {};
\r
847 HeaderView.prototype.showPetStore = function(e) {
\r
848 return this.trigger('update-swagger-ui', {
\r
849 url: "http://petstore.swagger.wordnik.com/api/api-docs"
\r
853 HeaderView.prototype.showWordnikDev = function(e) {
\r
854 return this.trigger('update-swagger-ui', {
\r
855 url: "http://api.wordnik.com/v4/resources.json"
\r
859 HeaderView.prototype.showCustomOnKeyup = function(e) {
\r
860 if (e.keyCode === 13) {
\r
861 return this.showCustom();
\r
865 HeaderView.prototype.showCustom = function(e) {
\r
867 e.preventDefault();
\r
869 return this.trigger('update-swagger-ui', {
\r
870 url: $('#input_baseUrl').val(),
\r
871 apiKey: $('#input_apiKey').val()
\r
875 HeaderView.prototype.update = function(url, apiKey, trigger) {
\r
876 if (trigger == null) {
\r
879 $('#input_baseUrl').val(url);
\r
881 return this.trigger('update-swagger-ui', {
\r
891 this["Handlebars"]["templates"]["param_list"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
892 return " multiple='multiple'";
\r
893 },"3":function(depth0,helpers,partials,data) {
\r
895 },"5":function(depth0,helpers,partials,data) {
\r
896 var stack1, buffer = "";
\r
897 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});
\r
898 if (stack1 != null) { buffer += stack1; }
\r
900 },"6":function(depth0,helpers,partials,data) {
\r
901 var stack1, helperMissing=helpers.helperMissing, buffer = "";
\r
902 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}));
\r
903 if (stack1 != null) { buffer += stack1; }
\r
905 },"7":function(depth0,helpers,partials,data) {
\r
906 return " <option selected=\"\" value=''></option>\n";
\r
907 },"9":function(depth0,helpers,partials,data) {
\r
908 var stack1, buffer = "";
\r
909 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});
\r
910 if (stack1 != null) { buffer += stack1; }
\r
912 },"10":function(depth0,helpers,partials,data) {
\r
913 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
914 return " <option selected=\"\" value='"
\r
915 + 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)))
\r
917 + 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)))
\r
918 + " (default)</option>\n";
\r
919 },"12":function(depth0,helpers,partials,data) {
\r
920 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
921 return " <option value='"
\r
922 + 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)))
\r
924 + 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)))
\r
926 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
927 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
\r
928 + escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
\r
929 + "</td>\n<td>\n <select ";
\r
930 stack1 = ((helpers.isArray || (depth0 && depth0.isArray) || helperMissing).call(depth0, depth0, {"name":"isArray","hash":{},"fn":this.program(1, data),"inverse":this.noop,"data":data}));
\r
931 if (stack1 != null) { buffer += stack1; }
\r
932 buffer += " class='parameter' name='"
\r
933 + 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)))
\r
935 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});
\r
936 if (stack1 != null) { buffer += stack1; }
\r
937 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});
\r
938 if (stack1 != null) { buffer += stack1; }
\r
939 buffer += " </select>\n</td>\n<td class=\"markdown\">";
\r
940 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));
\r
941 if (stack1 != null) { buffer += stack1; }
\r
942 buffer += "</td>\n<td>";
\r
943 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));
\r
944 if (stack1 != null) { buffer += stack1; }
\r
945 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>";
\r
946 },"useData":true});
\r
948 __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; },
\r
949 __hasProp = {}.hasOwnProperty;
\r
951 MainView = (function(_super) {
\r
954 __extends(MainView, _super);
\r
956 function MainView() {
\r
957 return MainView.__super__.constructor.apply(this, arguments);
\r
961 'alpha': function(a, b) {
\r
962 return a.path.localeCompare(b.path);
\r
964 'method': function(a, b) {
\r
965 return a.method.localeCompare(b.method);
\r
969 MainView.prototype.initialize = function(opts) {
\r
970 var auth, key, value, _ref;
\r
971 if (opts == null) {
\r
974 this.model.auths = [];
\r
975 _ref = this.model.securityDefinitions;
\r
976 for (key in _ref) {
\r
983 this.model.auths.push(auth);
\r
985 if (this.model.swaggerVersion === "2.0") {
\r
986 if ("validatorUrl" in opts.swaggerOptions) {
\r
987 return this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
\r
988 } else if (this.model.url.indexOf("localhost") > 0) {
\r
989 return this.model.validatorUrl = null;
\r
991 return this.model.validatorUrl = "http://online.swagger.io/validator";
\r
996 MainView.prototype.render = function() {
\r
997 var auth, button, counter, id, name, resource, resources, _i, _len, _ref;
\r
998 if (this.model.securityDefinitions) {
\r
999 for (name in this.model.securityDefinitions) {
\r
1000 auth = this.model.securityDefinitions[name];
\r
1001 if (auth.type === "apiKey" && $("#apikey_button").length === 0) {
\r
1002 button = new ApiKeyButton({
\r
1005 $('.auth_main_container').append(button);
\r
1007 if (auth.type === "basicAuth" && $("#basic_auth_button").length === 0) {
\r
1008 button = new BasicAuthButton({
\r
1011 $('.auth_main_container').append(button);
\r
1015 $(this.el).html(Handlebars.templates.main(this.model));
\r
1018 _ref = this.model.apisArray;
\r
1019 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
\r
1020 resource = _ref[_i];
\r
1021 id = resource.name;
\r
1022 while (typeof resources[id] !== 'undefined') {
\r
1023 id = id + "_" + counter;
\r
1027 resources[id] = resource;
\r
1028 this.addResource(resource, this.model.auths);
\r
1030 $('.propWrap').hover(function() {
\r
1031 return $('.optionsWrapper', $(this)).show();
\r
1033 return $('.optionsWrapper', $(this)).hide();
\r
1038 MainView.prototype.addResource = function(resource, auths) {
\r
1040 resource.id = resource.id.replace(/\s/g, '_');
\r
1041 resourceView = new ResourceView({
\r
1044 id: 'resource_' + resource.id,
\r
1045 className: 'resource',
\r
1047 swaggerOptions: this.options.swaggerOptions
\r
1049 return $('#resources').append(resourceView.render().el);
\r
1052 MainView.prototype.clear = function() {
\r
1053 return $(this.el).html('');
\r
1058 })(Backbone.View);
\r
1060 this["Handlebars"]["templates"]["param_readonly"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
1061 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1062 return " <textarea class='body-textarea' readonly='readonly' name='"
\r
1063 + 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)))
\r
1065 + 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)))
\r
1066 + "</textarea>\n";
\r
1067 },"3":function(depth0,helpers,partials,data) {
\r
1068 var stack1, buffer = "";
\r
1069 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});
\r
1070 if (stack1 != null) { buffer += stack1; }
\r
1072 },"4":function(depth0,helpers,partials,data) {
\r
1073 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1075 + 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)))
\r
1077 },"6":function(depth0,helpers,partials,data) {
\r
1078 return " (empty)\n";
\r
1079 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
1080 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code'>"
\r
1081 + 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)))
\r
1082 + "</td>\n<td>\n";
\r
1083 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});
\r
1084 if (stack1 != null) { buffer += stack1; }
\r
1085 buffer += "</td>\n<td class=\"markdown\">";
\r
1086 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));
\r
1087 if (stack1 != null) { buffer += stack1; }
\r
1088 buffer += "</td>\n<td>";
\r
1089 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));
\r
1090 if (stack1 != null) { buffer += stack1; }
\r
1091 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
\r
1092 },"useData":true});
\r
1093 this["Handlebars"]["templates"]["param_readonly_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
1094 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1095 return " <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='"
\r
1096 + 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)))
\r
1098 + 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)))
\r
1099 + "</textarea>\n";
\r
1100 },"3":function(depth0,helpers,partials,data) {
\r
1101 var stack1, buffer = "";
\r
1102 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});
\r
1103 if (stack1 != null) { buffer += stack1; }
\r
1105 },"4":function(depth0,helpers,partials,data) {
\r
1106 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1108 + 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)))
\r
1110 },"6":function(depth0,helpers,partials,data) {
\r
1111 return " (empty)\n";
\r
1112 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
1113 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
\r
1114 + 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)))
\r
1115 + "</td>\n<td>\n";
\r
1116 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});
\r
1117 if (stack1 != null) { buffer += stack1; }
\r
1118 buffer += "</td>\n<td class=\"markdown\">";
\r
1119 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));
\r
1120 if (stack1 != null) { buffer += stack1; }
\r
1121 buffer += "</td>\n<td>";
\r
1122 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));
\r
1123 if (stack1 != null) { buffer += stack1; }
\r
1124 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
\r
1125 },"useData":true});
\r
1126 var OperationView,
\r
1127 __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; },
\r
1128 __hasProp = {}.hasOwnProperty;
\r
1130 OperationView = (function(_super) {
\r
1131 __extends(OperationView, _super);
\r
1133 function OperationView() {
\r
1134 return OperationView.__super__.constructor.apply(this, arguments);
\r
1137 OperationView.prototype.invocationUrl = null;
\r
1139 OperationView.prototype.events = {
\r
1140 'submit .sandbox': 'submitOperation',
\r
1141 'click .submit': 'submitOperation',
\r
1142 'click .response_hider': 'hideResponse',
\r
1143 'click .toggleOperation': 'toggleOperationContent',
\r
1144 'mouseenter .api-ic': 'mouseEnter',
\r
1145 'mouseout .api-ic': 'mouseExit'
\r
1148 OperationView.prototype.initialize = function(opts) {
\r
1149 if (opts == null) {
\r
1152 this.auths = opts.auths;
\r
1153 this.parentId = this.model.parentId;
\r
1154 this.nickname = this.model.nickname;
\r
1158 OperationView.prototype.mouseEnter = function(e) {
\r
1159 var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
\r
1160 elem = $(this.el).find('.content');
\r
1163 scX = $(window).scrollLeft();
\r
1164 scY = $(window).scrollTop();
\r
1165 scMaxX = scX + $(window).width();
\r
1166 scMaxY = scY + $(window).height();
\r
1167 wd = elem.width();
\r
1168 hgh = elem.height();
\r
1169 if (x + wd > scMaxX) {
\r
1175 if (y + hgh > scMaxY) {
\r
1185 return $(e.currentTarget.parentNode).find('#api_information_panel').show();
\r
1188 OperationView.prototype.mouseExit = function(e) {
\r
1189 return $(e.currentTarget.parentNode).find('#api_information_panel').hide();
\r
1192 OperationView.prototype.render = function() {
\r
1193 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;
\r
1194 isMethodSubmissionSupported = jQuery.inArray(this.model.method, this.model.supportedSubmitMethods()) >= 0;
\r
1195 if (!isMethodSubmissionSupported) {
\r
1196 this.model.isReadOnly = true;
\r
1198 this.model.description = this.model.description || this.model.notes;
\r
1199 if (this.model.description) {
\r
1200 this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
\r
1202 this.model.oauth = null;
\r
1203 modelAuths = this.model.authorizations || this.model.security;
\r
1205 if (Array.isArray(modelAuths)) {
\r
1206 for (_i = 0, _len = modelAuths.length; _i < _len; _i++) {
\r
1207 auths = modelAuths[_i];
\r
1208 for (key in auths) {
\r
1209 auth = auths[key];
\r
1210 for (a in this.auths) {
\r
1211 auth = this.auths[a];
\r
1212 if (auth.type === 'oauth2') {
\r
1213 this.model.oauth = {};
\r
1214 this.model.oauth.scopes = [];
\r
1215 _ref = auth.value.scopes;
\r
1218 scopeIndex = auths[key].indexOf(k);
\r
1219 if (scopeIndex >= 0) {
\r
1224 this.model.oauth.scopes.push(o);
\r
1232 for (k in modelAuths) {
\r
1233 v = modelAuths[k];
\r
1234 if (k === "oauth2") {
\r
1235 if (this.model.oauth === null) {
\r
1236 this.model.oauth = {};
\r
1238 if (this.model.oauth.scopes === void 0) {
\r
1239 this.model.oauth.scopes = [];
\r
1241 for (_j = 0, _len1 = v.length; _j < _len1; _j++) {
\r
1243 this.model.oauth.scopes.push(o);
\r
1249 if (typeof this.model.responses !== 'undefined') {
\r
1250 this.model.responseMessages = [];
\r
1251 _ref1 = this.model.responses;
\r
1252 for (code in _ref1) {
\r
1253 value = _ref1[code];
\r
1255 schemaObj = this.model.responses[code].schema;
\r
1256 if (schemaObj && schemaObj['$ref']) {
\r
1257 schema = schemaObj['$ref'];
\r
1258 if (schema.indexOf('#/definitions/') === 0) {
\r
1259 schema = schema.substring('#/definitions/'.length);
\r
1262 this.model.responseMessages.push({
\r
1264 message: value.description,
\r
1265 responseModel: schema
\r
1269 if (typeof this.model.responseMessages === 'undefined') {
\r
1270 this.model.responseMessages = [];
\r
1272 signatureModel = null;
\r
1273 if (this.model.successResponse) {
\r
1274 successResponse = this.model.successResponse;
\r
1275 for (key in successResponse) {
\r
1276 value = successResponse[key];
\r
1277 this.model.successCode = key;
\r
1278 if (typeof value === 'object' && typeof value.createJSONSample === 'function') {
\r
1279 signatureModel = {
\r
1280 sampleJSON: JSON.stringify(value.createJSONSample(), void 0, 2),
\r
1282 signature: value.getMockSignature()
\r
1286 } else if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
\r
1287 signatureModel = {
\r
1288 sampleJSON: this.model.responseSampleJSON,
\r
1290 signature: this.model.responseClassSignature
\r
1293 $(this.el).html(Handlebars.templates.operation(this.model));
\r
1294 if (signatureModel) {
\r
1295 responseSignatureView = new SignatureView({
\r
1296 model: signatureModel,
\r
1299 $('.model-signature', $(this.el)).append(responseSignatureView.render().el);
\r
1301 this.model.responseClassSignature = 'string';
\r
1302 $('.model-signature', $(this.el)).html(this.model.type);
\r
1304 contentTypeModel = {
\r
1307 contentTypeModel.consumes = this.model.consumes;
\r
1308 contentTypeModel.produces = this.model.produces;
\r
1309 _ref2 = this.model.parameters;
\r
1310 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
\r
1311 param = _ref2[_k];
\r
1312 type = param.type || param.dataType || '';
\r
1313 if (typeof type === 'undefined') {
\r
1314 schema = param.schema;
\r
1315 if (schema && schema['$ref']) {
\r
1316 ref = schema['$ref'];
\r
1317 if (ref.indexOf('#/definitions/') === 0) {
\r
1318 type = ref.substring('#/definitions/'.length);
\r
1324 if (type && type.toLowerCase() === 'file') {
\r
1325 if (!contentTypeModel.consumes) {
\r
1326 contentTypeModel.consumes = 'multipart/form-data';
\r
1329 param.type = type;
\r
1331 responseContentTypeView = new ResponseContentTypeView({
\r
1332 model: contentTypeModel
\r
1334 $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
\r
1335 _ref3 = this.model.parameters;
\r
1336 for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
\r
1337 param = _ref3[_l];
\r
1338 this.addParameter(param, contentTypeModel.consumes);
\r
1340 _ref4 = this.model.responseMessages;
\r
1341 for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
\r
1342 statusCode = _ref4[_m];
\r
1343 this.addStatusCode(statusCode);
\r
1348 OperationView.prototype.addParameter = function(param, consumes) {
\r
1350 param.consumes = consumes;
\r
1351 paramView = new ParameterView({
\r
1354 readOnly: this.model.isReadOnly
\r
1356 return $('.operation-params', $(this.el)).append(paramView.render().el);
\r
1359 OperationView.prototype.addStatusCode = function(statusCode) {
\r
1360 var statusCodeView;
\r
1361 statusCodeView = new StatusCodeView({
\r
1362 model: statusCode,
\r
1365 return $('.operation-status', $(this.el)).append(statusCodeView.render().el);
\r
1368 OperationView.prototype.submitOperation = function(e) {
\r
1369 var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
\r
1371 e.preventDefault();
\r
1373 form = $('.sandbox', $(this.el));
\r
1374 error_free = true;
\r
1375 form.find("input.required").each(function() {
\r
1376 $(this).removeClass("error");
\r
1377 if (jQuery.trim($(this).val()) === "") {
\r
1378 $(this).addClass("error");
\r
1380 callback: (function(_this) {
\r
1381 return function() {
\r
1382 return $(_this).focus();
\r
1386 return error_free = false;
\r
1389 form.find("textarea.required").each(function() {
\r
1390 $(this).removeClass("error");
\r
1391 if (jQuery.trim($(this).val()) === "") {
\r
1392 $(this).addClass("error");
\r
1394 callback: (function(_this) {
\r
1395 return function() {
\r
1396 return $(_this).focus();
\r
1400 return error_free = false;
\r
1408 isFileUpload = false;
\r
1409 _ref = form.find("input");
\r
1410 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
\r
1412 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
\r
1413 map[o.name] = o.value;
\r
1415 if (o.type === "file") {
\r
1416 map[o.name] = o.files[0];
\r
1417 isFileUpload = true;
\r
1420 _ref1 = form.find("textarea");
\r
1421 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
\r
1423 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
\r
1424 map[o.name] = o.value;
\r
1427 _ref2 = form.find("select");
\r
1428 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
\r
1430 val = this.getSelectedValue(o);
\r
1431 if ((val != null) && jQuery.trim(val).length > 0) {
\r
1432 map[o.name] = val;
\r
1435 opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val();
\r
1436 opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val();
\r
1437 $(".response_throbber", $(this.el)).show();
\r
1438 if (isFileUpload) {
\r
1439 return this.handleFileUpload(map, form);
\r
1441 return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
\r
1446 OperationView.prototype.success = function(response, parent) {
\r
1447 return parent.showCompleteStatus(response);
\r
1450 OperationView.prototype.handleFileUpload = function(map, form) {
\r
1451 var bodyParam, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
\r
1452 _ref = form.serializeArray();
\r
1453 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
\r
1455 if ((o.value != null) && jQuery.trim(o.value).length > 0) {
\r
1456 map[o.name] = o.value;
\r
1459 bodyParam = new FormData();
\r
1461 _ref1 = this.model.parameters;
\r
1462 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
\r
1463 param = _ref1[_j];
\r
1464 if (param.paramType === 'form' || param["in"] === 'formData') {
\r
1465 if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) {
\r
1466 bodyParam.append(param.name, map[param.name]);
\r
1470 headerParams = {};
\r
1471 _ref2 = this.model.parameters;
\r
1472 for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
\r
1473 param = _ref2[_k];
\r
1474 if (param.paramType === 'header') {
\r
1475 headerParams[param.name] = map[param.name];
\r
1478 _ref3 = form.find('input[type~="file"]');
\r
1479 for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
\r
1481 if (typeof el.files[0] !== 'undefined') {
\r
1482 bodyParam.append($(el).attr('name'), el.files[0]);
\r
1486 this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), delete headerParams['Content-Type'], this.model.urlify(map, false)) : this.model.urlify(map, true);
\r
1487 $(".request_url", $(this.el)).html("<pre></pre>");
\r
1488 $(".request_url pre", $(this.el)).text(this.invocationUrl);
\r
1490 type: this.model.method,
\r
1491 url: this.invocationUrl,
\r
1492 headers: headerParams,
\r
1495 contentType: false,
\r
1496 processData: false,
\r
1497 error: (function(_this) {
\r
1498 return function(data, textStatus, error) {
\r
1499 return _this.showErrorStatus(_this.wrap(data), _this);
\r
1502 success: (function(_this) {
\r
1503 return function(data) {
\r
1504 return _this.showResponse(data, _this);
\r
1507 complete: (function(_this) {
\r
1508 return function(data) {
\r
1509 return _this.showCompleteStatus(_this.wrap(data), _this);
\r
1513 if (window.authorizations) {
\r
1514 window.authorizations.apply(obj);
\r
1516 if (params === 0) {
\r
1517 obj.data.append("fake", "true");
\r
1523 OperationView.prototype.wrap = function(data) {
\r
1524 var h, headerArray, headers, i, o, _i, _len;
\r
1526 headerArray = data.getAllResponseHeaders().split("\r");
\r
1527 for (_i = 0, _len = headerArray.length; _i < _len; _i++) {
\r
1528 i = headerArray[_i];
\r
1529 h = i.match(/^([^:]*?):(.*)$/);
\r
1534 if (h[0] !== void 0 && h[1] !== void 0) {
\r
1535 headers[h[0].trim()] = h[1].trim();
\r
1540 o.content.data = data.responseText;
\r
1541 o.headers = headers;
\r
1543 o.request.url = this.invocationUrl;
\r
1544 o.status = data.status;
\r
1548 OperationView.prototype.getSelectedValue = function(select) {
\r
1549 var opt, options, _i, _len, _ref;
\r
1550 if (!select.multiple) {
\r
1551 return select.value;
\r
1554 _ref = select.options;
\r
1555 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
\r
1557 if (opt.selected) {
\r
1558 options.push(opt.value);
\r
1561 if (options.length > 0) {
\r
1569 OperationView.prototype.hideResponse = function(e) {
\r
1571 e.preventDefault();
\r
1573 $(".response", $(this.el)).slideUp();
\r
1574 return $(".response_hider", $(this.el)).fadeOut();
\r
1577 OperationView.prototype.showResponse = function(response) {
\r
1579 prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
\r
1580 return $(".response_body", $(this.el)).html(escape(prettyJson));
\r
1583 OperationView.prototype.showErrorStatus = function(data, parent) {
\r
1584 return parent.showStatus(data);
\r
1587 OperationView.prototype.showCompleteStatus = function(data, parent) {
\r
1588 return parent.showStatus(data);
\r
1591 OperationView.prototype.formatXml = function(xml) {
\r
1592 var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
\r
1593 reg = /(>)(<)(\/*)/g;
\r
1594 wsexp = /[ ]*(.*)[ ]+\n/g;
\r
1595 contexp = /(<.+>)(.+\n)/g;
\r
1596 xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
\r
1599 lines = xml.split('\n');
\r
1601 lastType = 'other';
\r
1603 'single->single': 0,
\r
1604 'single->closing': -1,
\r
1605 'single->opening': 0,
\r
1606 'single->other': 0,
\r
1607 'closing->single': 0,
\r
1608 'closing->closing': -1,
\r
1609 'closing->opening': 0,
\r
1610 'closing->other': 0,
\r
1611 'opening->single': 1,
\r
1612 'opening->closing': 0,
\r
1613 'opening->opening': 1,
\r
1614 'opening->other': 1,
\r
1615 'other->single': 0,
\r
1616 'other->closing': -1,
\r
1617 'other->opening': 0,
\r
1620 _fn = function(ln) {
\r
1621 var fromTo, j, key, padding, type, types, value;
\r
1623 single: Boolean(ln.match(/<.+\/>/)),
\r
1624 closing: Boolean(ln.match(/<\/.+>/)),
\r
1625 opening: Boolean(ln.match(/<[^!?].*>/))
\r
1627 type = ((function() {
\r
1630 for (key in types) {
\r
1631 value = types[key];
\r
1633 _results.push(key);
\r
1638 type = type === void 0 ? 'other' : type;
\r
1639 fromTo = lastType + '->' + type;
\r
1642 indent += transitions[fromTo];
\r
1643 padding = ((function() {
\r
1644 var _j, _ref, _results;
\r
1646 for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
\r
1647 _results.push(' ');
\r
1651 if (fromTo === 'opening->closing') {
\r
1652 return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
\r
1654 return formatted += padding + ln + '\n';
\r
1657 for (_i = 0, _len = lines.length; _i < _len; _i++) {
\r
1664 OperationView.prototype.showStatus = function(response) {
\r
1665 var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url;
\r
1666 if (response.content === void 0) {
\r
1667 content = response.data;
\r
1668 url = response.url;
\r
1670 content = response.content.data;
\r
1671 url = response.request.url;
\r
1673 headers = response.headers;
\r
1674 contentType = null;
\r
1676 contentType = headers["Content-Type"] || headers["content-type"];
\r
1677 if (contentType) {
\r
1678 contentType = contentType.split(";")[0].trim();
\r
1681 $(".response_body", $(this.el)).removeClass('json');
\r
1682 $(".response_body", $(this.el)).removeClass('xml');
\r
1684 code = $('<code />').text("no content");
\r
1685 pre = $('<pre class="json" />').append(code);
\r
1686 } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
\r
1689 json = JSON.stringify(JSON.parse(content), null, " ");
\r
1690 } catch (_error) {
\r
1692 json = "can't parse JSON. Raw result:\n\n" + content;
\r
1694 code = $('<code />').text(json);
\r
1695 pre = $('<pre class="json" />').append(code);
\r
1696 } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
\r
1697 code = $('<code />').text(this.formatXml(content));
\r
1698 pre = $('<pre class="xml" />').append(code);
\r
1699 } else if (contentType === "text/html") {
\r
1700 code = $('<code />').html(_.escape(content));
\r
1701 pre = $('<pre class="xml" />').append(code);
\r
1702 } else if (/^image\//.test(contentType)) {
\r
1703 pre = $('<img>').attr('src', url);
\r
1705 code = $('<code />').text(content);
\r
1706 pre = $('<pre class="json" />').append(code);
\r
1708 response_body = pre;
\r
1709 $(".request_url", $(this.el)).html("<pre></pre>");
\r
1710 $(".request_url pre", $(this.el)).text(url);
\r
1711 $(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
\r
1712 $(".response_body", $(this.el)).html(response_body);
\r
1713 $(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
\r
1714 $(".response", $(this.el)).slideDown();
\r
1715 $(".response_hider", $(this.el)).show();
\r
1716 $(".response_throbber", $(this.el)).hide();
\r
1717 response_body_el = $('.response_body', $(this.el))[0];
\r
1718 opts = this.options.swaggerOptions;
\r
1719 if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
\r
1720 return response_body_el;
\r
1722 return hljs.highlightBlock(response_body_el);
\r
1726 OperationView.prototype.toggleOperationContent = function() {
\r
1728 elem = $('#' + Docs.escapeResourceName(this.parentId + "_" + this.nickname + "_content"));
\r
1729 if (elem.is(':visible')) {
\r
1730 return Docs.collapseOperation(elem);
\r
1732 return Docs.expandOperation(elem);
\r
1736 return OperationView;
\r
1738 })(Backbone.View);
\r
1740 var ParameterContentTypeView,
\r
1741 __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; },
\r
1742 __hasProp = {}.hasOwnProperty;
\r
1744 ParameterContentTypeView = (function(_super) {
\r
1745 __extends(ParameterContentTypeView, _super);
\r
1747 function ParameterContentTypeView() {
\r
1748 return ParameterContentTypeView.__super__.constructor.apply(this, arguments);
\r
1751 ParameterContentTypeView.prototype.initialize = function() {};
\r
1753 ParameterContentTypeView.prototype.render = function() {
\r
1755 template = this.template();
\r
1756 $(this.el).html(template(this.model));
\r
1757 $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:');
\r
1761 ParameterContentTypeView.prototype.template = function() {
\r
1762 return Handlebars.templates.parameter_content_type;
\r
1765 return ParameterContentTypeView;
\r
1767 })(Backbone.View);
\r
1769 this["Handlebars"]["templates"]["param_required"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
1770 var stack1, buffer = "";
\r
1771 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});
\r
1772 if (stack1 != null) { buffer += stack1; }
\r
1774 },"2":function(depth0,helpers,partials,data) {
\r
1775 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1776 return " <input type=\"file\" name='"
\r
1777 + 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)))
\r
1779 },"4":function(depth0,helpers,partials,data) {
\r
1780 var stack1, buffer = "";
\r
1781 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});
\r
1782 if (stack1 != null) { buffer += stack1; }
\r
1784 },"5":function(depth0,helpers,partials,data) {
\r
1785 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1786 return " <textarea class='body-textarea required' placeholder='(required)' name='"
\r
1787 + 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)))
\r
1789 + 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)))
\r
1790 + "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
\r
1791 },"7":function(depth0,helpers,partials,data) {
\r
1792 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1793 return " <textarea class='body-textarea required' placeholder='(required)' name='"
\r
1794 + 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)))
\r
1795 + "'></textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
\r
1796 },"9":function(depth0,helpers,partials,data) {
\r
1797 var stack1, buffer = "";
\r
1798 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});
\r
1799 if (stack1 != null) { buffer += stack1; }
\r
1801 },"10":function(depth0,helpers,partials,data) {
\r
1802 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1803 return " <input class='parameter' class='required' type='file' name='"
\r
1804 + 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)))
\r
1806 },"12":function(depth0,helpers,partials,data) {
\r
1807 var stack1, buffer = "";
\r
1808 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});
\r
1809 if (stack1 != null) { buffer += stack1; }
\r
1811 },"13":function(depth0,helpers,partials,data) {
\r
1812 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1813 return " <input class='parameter required' minlength='1' name='"
\r
1814 + 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)))
\r
1815 + "' placeholder='(required)' type='text' value='"
\r
1816 + 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)))
\r
1818 },"15":function(depth0,helpers,partials,data) {
\r
1819 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
1820 return " <input class='parameter required' minlength='1' name='"
\r
1821 + 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)))
\r
1822 + "' placeholder='(required)' type='text' value=''/>\n";
\r
1823 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
1824 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td class='code required'>"
\r
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)))
\r
1826 + "</td>\n<td>\n";
\r
1827 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});
\r
1828 if (stack1 != null) { buffer += stack1; }
\r
1829 buffer += "</td>\n<td>\n <strong><span class=\"markdown\">";
\r
1830 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));
\r
1831 if (stack1 != null) { buffer += stack1; }
\r
1832 buffer += "</span></strong>\n</td>\n<td>";
\r
1833 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));
\r
1834 if (stack1 != null) { buffer += stack1; }
\r
1835 return buffer + "</td>\n<td><span class=\"model-signature\"></span></td>\n";
\r
1836 },"useData":true});
\r
1837 this["Handlebars"]["templates"]["parameter_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
1838 var stack1, buffer = "";
\r
1839 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.consumes : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
\r
1840 if (stack1 != null) { buffer += stack1; }
\r
1842 },"2":function(depth0,helpers,partials,data) {
\r
1843 var stack1, lambda=this.lambda, buffer = " <option value=\"";
\r
1844 stack1 = lambda(depth0, depth0);
\r
1845 if (stack1 != null) { buffer += stack1; }
\r
1847 stack1 = lambda(depth0, depth0);
\r
1848 if (stack1 != null) { buffer += stack1; }
\r
1849 return buffer + "</option>\n";
\r
1850 },"4":function(depth0,helpers,partials,data) {
\r
1851 return " <option value=\"application/json\">application/json</option>\n";
\r
1852 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
1853 var stack1, buffer = "<label for=\"parameterContentType\"></label>\n<select name=\"parameterContentType\">\n";
\r
1854 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});
\r
1855 if (stack1 != null) { buffer += stack1; }
\r
1856 return buffer + "</select>\n";
\r
1857 },"useData":true});
\r
1858 var ParameterView,
\r
1859 __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; },
\r
1860 __hasProp = {}.hasOwnProperty;
\r
1862 ParameterView = (function(_super) {
\r
1863 __extends(ParameterView, _super);
\r
1865 function ParameterView() {
\r
1866 return ParameterView.__super__.constructor.apply(this, arguments);
\r
1869 ParameterView.prototype.initialize = function() {
\r
1870 return Handlebars.registerHelper('isArray', function(param, opts) {
\r
1871 if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
\r
1872 return opts.fn(this);
\r
1874 return opts.inverse(this);
\r
1879 ParameterView.prototype.render = function() {
\r
1880 var contentTypeModel, isParam, parameterContentTypeView, ref, responseContentTypeView, schema, signatureModel, signatureView, template, type;
\r
1881 type = this.model.type || this.model.dataType;
\r
1882 if (typeof type === 'undefined') {
\r
1883 schema = this.model.schema;
\r
1884 if (schema && schema['$ref']) {
\r
1885 ref = schema['$ref'];
\r
1886 if (ref.indexOf('#/definitions/') === 0) {
\r
1887 type = ref.substring('#/definitions/'.length);
\r
1893 this.model.type = type;
\r
1894 this.model.paramType = this.model["in"] || this.model.paramType;
\r
1895 if (this.model.paramType === 'body' || this.model["in"] === 'body') {
\r
1896 this.model.isBody = true;
\r
1898 if (type && type.toLowerCase() === 'file') {
\r
1899 this.model.isFile = true;
\r
1901 this.model["default"] = this.model["default"] || this.model.defaultValue;
\r
1902 if (this.model.allowableValues) {
\r
1903 this.model.isList = true;
\r
1905 template = this.template();
\r
1906 $(this.el).html(template(this.model));
\r
1907 signatureModel = {
\r
1908 sampleJSON: this.model.sampleJSON,
\r
1910 signature: this.model.signature
\r
1912 if (this.model.sampleJSON) {
\r
1913 signatureView = new SignatureView({
\r
1914 model: signatureModel,
\r
1917 $('.model-signature', $(this.el)).append(signatureView.render().el);
\r
1919 $('.model-signature', $(this.el)).html(this.model.signature);
\r
1922 if (this.model.isBody) {
\r
1925 contentTypeModel = {
\r
1928 contentTypeModel.consumes = this.model.consumes;
\r
1930 parameterContentTypeView = new ParameterContentTypeView({
\r
1931 model: contentTypeModel
\r
1933 $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el);
\r
1935 responseContentTypeView = new ResponseContentTypeView({
\r
1936 model: contentTypeModel
\r
1938 $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
\r
1943 ParameterView.prototype.template = function() {
\r
1944 if (this.model.isList) {
\r
1945 return Handlebars.templates.param_list;
\r
1947 if (this.options.readOnly) {
\r
1948 if (this.model.required) {
\r
1949 return Handlebars.templates.param_readonly_required;
\r
1951 return Handlebars.templates.param_readonly;
\r
1954 if (this.model.required) {
\r
1955 return Handlebars.templates.param_required;
\r
1957 return Handlebars.templates.param;
\r
1963 return ParameterView;
\r
1965 })(Backbone.View);
\r
1968 __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; },
\r
1969 __hasProp = {}.hasOwnProperty;
\r
1971 ResourceView = (function(_super) {
\r
1972 __extends(ResourceView, _super);
\r
1974 function ResourceView() {
\r
1975 return ResourceView.__super__.constructor.apply(this, arguments);
\r
1978 ResourceView.prototype.initialize = function(opts) {
\r
1979 if (opts == null) {
\r
1982 this.auths = opts.auths;
\r
1983 if ("" === this.model.description) {
\r
1984 this.model.description = null;
\r
1986 if (this.model.description != null) {
\r
1987 return this.model.summary = this.model.description;
\r
1991 ResourceView.prototype.render = function() {
\r
1992 var counter, id, methods, operation, _i, _len, _ref;
\r
1994 $(this.el).html(Handlebars.templates.resource(this.model));
\r
1995 _ref = this.model.operationsArray;
\r
1996 for (_i = 0, _len = _ref.length; _i < _len; _i++) {
\r
1997 operation = _ref[_i];
\r
1999 id = operation.nickname;
\r
2000 while (typeof methods[id] !== 'undefined') {
\r
2001 id = id + "_" + counter;
\r
2004 methods[id] = operation;
\r
2005 operation.nickname = id;
\r
2006 operation.parentId = this.model.id;
\r
2007 this.addOperation(operation);
\r
2009 $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
\r
2010 $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
\r
2011 $('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
\r
2015 ResourceView.prototype.addOperation = function(operation) {
\r
2016 var operationView;
\r
2017 operation.number = this.number;
\r
2018 operationView = new OperationView({
\r
2021 className: 'endpoint',
\r
2022 swaggerOptions: this.options.swaggerOptions,
\r
2025 $('.endpoints', $(this.el)).append(operationView.render().el);
\r
2026 return this.number++;
\r
2029 ResourceView.prototype.callDocs = function(fnName, e) {
\r
2030 e.preventDefault();
\r
2031 return Docs[fnName](e.currentTarget.getAttribute('data-id'));
\r
2034 return ResourceView;
\r
2036 })(Backbone.View);
\r
2038 this["Handlebars"]["templates"]["resource"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
2040 },"3":function(depth0,helpers,partials,data) {
\r
2041 var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
\r
2042 return "<li>\n <a href='"
\r
2043 + 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)))
\r
2044 + "'>Raw</a>\n </li>";
\r
2045 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
2046 var stack1, helper, options, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, blockHelperMissing=helpers.blockHelperMissing, buffer = "<div class='heading'>\n <h2>\n <a href='#!/"
\r
2047 + 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)))
\r
2048 + "' class=\"toggleEndpointList\" data-id=\""
\r
2049 + 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)))
\r
2051 + 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)))
\r
2053 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));
\r
2054 if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
\r
2055 if (stack1 != null) { buffer += stack1; }
\r
2056 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));
\r
2057 if (stack1 != null) { buffer += stack1; }
\r
2058 buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/"
\r
2059 + 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)))
\r
2060 + "' id='endpointListTogger_"
\r
2061 + 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)))
\r
2062 + "' class=\"toggleEndpointList\" data-id=\""
\r
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)))
\r
2064 + "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\""
\r
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)))
\r
2066 + "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=\""
\r
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)))
\r
2068 + "\">\n Expand Operations\n </a>\n </li>\n ";
\r
2069 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));
\r
2070 if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
\r
2071 if (stack1 != null) { buffer += stack1; }
\r
2072 return buffer + "\n </ul>\n</div>\n<ul class='endpoints' id='"
\r
2073 + 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)))
\r
2074 + "_endpoint_list' style='display:none'>\n\n</ul>\n";
\r
2075 },"useData":true});
\r
2076 var ResponseContentTypeView,
\r
2077 __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; },
\r
2078 __hasProp = {}.hasOwnProperty;
\r
2080 ResponseContentTypeView = (function(_super) {
\r
2081 __extends(ResponseContentTypeView, _super);
\r
2083 function ResponseContentTypeView() {
\r
2084 return ResponseContentTypeView.__super__.constructor.apply(this, arguments);
\r
2087 ResponseContentTypeView.prototype.initialize = function() {};
\r
2089 ResponseContentTypeView.prototype.render = function() {
\r
2091 template = this.template();
\r
2092 $(this.el).html(template(this.model));
\r
2093 $('label[for=responseContentType]', $(this.el)).text('Response Content Type');
\r
2097 ResponseContentTypeView.prototype.template = function() {
\r
2098 return Handlebars.templates.response_content_type;
\r
2101 return ResponseContentTypeView;
\r
2103 })(Backbone.View);
\r
2105 this["Handlebars"]["templates"]["response_content_type"] = Handlebars.template({"1":function(depth0,helpers,partials,data) {
\r
2106 var stack1, buffer = "";
\r
2107 stack1 = helpers.each.call(depth0, (depth0 != null ? depth0.produces : depth0), {"name":"each","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
\r
2108 if (stack1 != null) { buffer += stack1; }
\r
2110 },"2":function(depth0,helpers,partials,data) {
\r
2111 var stack1, lambda=this.lambda, buffer = " <option value=\"";
\r
2112 stack1 = lambda(depth0, depth0);
\r
2113 if (stack1 != null) { buffer += stack1; }
\r
2115 stack1 = lambda(depth0, depth0);
\r
2116 if (stack1 != null) { buffer += stack1; }
\r
2117 return buffer + "</option>\n";
\r
2118 },"4":function(depth0,helpers,partials,data) {
\r
2119 return " <option value=\"application/json\">application/json</option>\n";
\r
2120 },"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
2121 var stack1, buffer = "<label for=\"responseContentType\"></label>\n<select name=\"responseContentType\">\n";
\r
2122 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});
\r
2123 if (stack1 != null) { buffer += stack1; }
\r
2124 return buffer + "</select>\n";
\r
2125 },"useData":true});
\r
2126 var SignatureView,
\r
2127 __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; },
\r
2128 __hasProp = {}.hasOwnProperty;
\r
2130 SignatureView = (function(_super) {
\r
2131 __extends(SignatureView, _super);
\r
2133 function SignatureView() {
\r
2134 return SignatureView.__super__.constructor.apply(this, arguments);
\r
2137 SignatureView.prototype.events = {
\r
2138 'click a.description-link': 'switchToDescription',
\r
2139 'click a.snippet-link': 'switchToSnippet',
\r
2140 'mousedown .snippet': 'snippetToTextArea'
\r
2143 SignatureView.prototype.initialize = function() {};
\r
2145 SignatureView.prototype.render = function() {
\r
2147 template = this.template();
\r
2148 $(this.el).html(template(this.model));
\r
2149 this.switchToSnippet();
\r
2150 this.isParam = this.model.isParam;
\r
2151 if (this.isParam) {
\r
2152 $('.notice', $(this.el)).text('Click to set as parameter value');
\r
2157 SignatureView.prototype.template = function() {
\r
2158 return Handlebars.templates.signature;
\r
2161 SignatureView.prototype.switchToDescription = function(e) {
\r
2163 e.preventDefault();
\r
2165 $(".snippet", $(this.el)).hide();
\r
2166 $(".description", $(this.el)).show();
\r
2167 $('.description-link', $(this.el)).addClass('selected');
\r
2168 return $('.snippet-link', $(this.el)).removeClass('selected');
\r
2171 SignatureView.prototype.switchToSnippet = function(e) {
\r
2173 e.preventDefault();
\r
2175 $(".description", $(this.el)).hide();
\r
2176 $(".snippet", $(this.el)).show();
\r
2177 $('.snippet-link', $(this.el)).addClass('selected');
\r
2178 return $('.description-link', $(this.el)).removeClass('selected');
\r
2181 SignatureView.prototype.snippetToTextArea = function(e) {
\r
2183 if (this.isParam) {
\r
2185 e.preventDefault();
\r
2187 textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode));
\r
2188 if ($.trim(textArea.val()) === '') {
\r
2189 return textArea.val(this.model.sampleJSON);
\r
2194 return SignatureView;
\r
2196 })(Backbone.View);
\r
2198 this["Handlebars"]["templates"]["signature"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
2199 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 ";
\r
2200 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));
\r
2201 if (stack1 != null) { buffer += stack1; }
\r
2202 return buffer + "\n </div>\n\n <div class=\"snippet\">\n <pre><code>"
\r
2203 + 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)))
\r
2204 + "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
\r
2205 },"useData":true});
\r
2206 var StatusCodeView,
\r
2207 __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; },
\r
2208 __hasProp = {}.hasOwnProperty;
\r
2210 StatusCodeView = (function(_super) {
\r
2211 __extends(StatusCodeView, _super);
\r
2213 function StatusCodeView() {
\r
2214 return StatusCodeView.__super__.constructor.apply(this, arguments);
\r
2217 StatusCodeView.prototype.initialize = function() {};
\r
2219 StatusCodeView.prototype.render = function() {
\r
2220 var responseModel, responseModelView, template;
\r
2221 template = this.template();
\r
2222 $(this.el).html(template(this.model));
\r
2223 if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) {
\r
2225 sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2),
\r
2227 signature: swaggerUi.api.models[this.model.responseModel].getMockSignature()
\r
2229 responseModelView = new SignatureView({
\r
2230 model: responseModel,
\r
2233 $('.model-signature', this.$el).append(responseModelView.render().el);
\r
2235 $('.model-signature', this.$el).html('');
\r
2240 StatusCodeView.prototype.template = function() {
\r
2241 return Handlebars.templates.status_code;
\r
2244 return StatusCodeView;
\r
2246 })(Backbone.View);
\r
2248 this["Handlebars"]["templates"]["status_code"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {
\r
2249 var stack1, helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression, buffer = "<td width='15%' class='code'>"
\r
2250 + 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)))
\r
2252 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));
\r
2253 if (stack1 != null) { buffer += stack1; }
\r
2254 return buffer + "</td>\n<td width='50%'><span class=\"model-signature\" /></td>";
\r