diff --git a/dist/index.html b/dist/index.html index 2f092c1f..44cc3717 100644 --- a/dist/index.html +++ b/dist/index.html @@ -2,7 +2,7 @@ Swagger UI - + @@ -23,25 +23,20 @@ dom_id: "swagger-ui-container", supportedSubmitMethods: ['get', 'post', 'put', 'delete'], onComplete: function(swaggerApi, swaggerUi){ - if(console) { - console.log("Loaded SwaggerUI") - } + log("Loaded SwaggerUI") $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); }, onFailure: function(data) { - if(console) { - console.log("Unable to Load SwaggerUI"); - console.log(data); - } + log("Unable to Load SwaggerUI"); }, docExpansion: "none" }); $('#input_apiKey').change(function() { var key = $('#input_apiKey')[0].value; - console.log("key: " + key); + log("key: " + key); if(key && key.trim() != "") { - console.log("added key " + key); + log("added key " + key); window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query")); } }) diff --git a/dist/lib/swagger.js b/dist/lib/swagger.js index c7bf2976..117e0c83 100644 --- a/dist/lib/swagger.js +++ b/dist/lib/swagger.js @@ -1,7 +1,8 @@ // Generated by CoffeeScript 1.6.3 (function() { var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; SwaggerApi = (function() { SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json"; @@ -16,6 +17,8 @@ SwaggerApi.prototype.info = null; + SwaggerApi.prototype.useJQuery = null; + function SwaggerApi(url, options) { if (options == null) { options = {}; @@ -47,6 +50,7 @@ _this = this; this.progress('fetching resource list: ' + this.url); obj = { + useJQuery: this.useJQuery, url: this.url, method: "get", headers: {}, @@ -62,14 +66,14 @@ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url); } }, - response: function(rawResponse) { - var response; - response = JSON.parse(rawResponse.content.data); - _this.swaggerVersion = response.swaggerVersion; + response: function(response) { + var responseObj; + responseObj = JSON.parse(response.data); + _this.swaggerVersion = responseObj.swaggerVersion; if (_this.swaggerVersion === "1.2") { - return _this.buildFromSpec(response); + return _this.buildFromSpec(responseObj); } else { - return _this.buildFrom1_1Spec(response); + return _this.buildFrom1_1Spec(responseObj); } } } @@ -139,7 +143,7 @@ SwaggerApi.prototype.buildFrom1_1Spec = function(response) { var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; - console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info"); + log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info"); if (response.apiVersion != null) { this.apiVersion = response.apiVersion; } @@ -241,15 +245,15 @@ _ref = this.apis; for (resource_name in _ref) { resource = _ref[resource_name]; - console.log(resource_name); + log(resource_name); _ref1 = resource.operations; for (operation_name in _ref1) { operation = _ref1[operation_name]; - console.log(" " + operation.nickname); + log(" " + operation.nickname); _ref2 = operation.parameters; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { parameter = _ref2[_i]; - console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); } } } @@ -283,6 +287,7 @@ this.operationsArray = []; this.modelsArray = []; this.models = {}; + this.rawModels = {}; if ((resourceObj.apis != null) && (this.api.resourcePath != null)) { this.addApiDeclaration(resourceObj); } else { @@ -298,15 +303,16 @@ obj = { url: this.url, method: "get", + useJQuery: this.useJQuery, headers: {}, on: { error: function(response) { return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")"); }, - response: function(rawResponse) { - var response; - response = JSON.parse(rawResponse.content.data); - return _this.addApiDeclaration(response); + response: function(response) { + var responseObj; + responseObj = JSON.parse(response.data); + return _this.addApiDeclaration(responseObj); } } }; @@ -372,6 +378,7 @@ swaggerModel = new SwaggerModel(modelName, models[modelName]); this.modelsArray.push(swaggerModel); this.models[modelName] = swaggerModel; + this.rawModels[modelName] = models[modelName]; } } _ref = this.modelsArray; @@ -522,7 +529,7 @@ _ref1 = this.properties; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { prop = _ref1[_j]; - if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) { + if ((prop.refModel != null) && (modelsToIgnore[prop.refModel] !== 'undefined') === -1) { returnVal = returnVal + ('
' + prop.refModel.getMockSignature(modelsToIgnore)); } } @@ -581,7 +588,7 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) { var result; - if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) { + if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) { result = this.refModel.createJSONSample(modelsToIgnore); } else { if (this.isCollection) { @@ -776,19 +783,19 @@ } if (error == null) { error = function(xhr, textStatus, error) { - return console.log(xhr, textStatus, error); + return log(xhr, textStatus, error); }; } if (callback == null) { - callback = function(data) { + callback = function(response) { var content; content = null; - if (data.content != null) { - content = data.content.data; + if (response != null) { + content = response.data; } else { content = "no data"; } - return console.log("default callback: " + content); + return log("default callback: " + content); }; } params = {}; @@ -1005,8 +1012,8 @@ } } if (requestContentType && this.operation.consumes) { - if (this.operation.consumes.indexOf(requestContentType) === -1) { - console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes)); + if (this.operation.consumes[requestContentType] === 'undefined') { + log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes)); if (this.requestContentType === null) { requestContentType = this.operation.consumes[0]; } @@ -1023,8 +1030,8 @@ responseContentType = null; } if (responseContentType && this.operation.produces) { - if (this.operation.produces.indexOf(responseContentType) === -1) { - console.log("server can't produce " + responseContentType); + if (this.operation.produces[responseContentType] === 'undefined') { + log("server can't produce " + responseContentType); } } if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) { @@ -1073,6 +1080,7 @@ method: this.type, headers: myHeaders, body: body, + useJQuery: this.useJQuery, on: { error: function(response) { return _this.errorCallback(response, _this.opts.parent); @@ -1102,7 +1110,6 @@ obj.canceled = true; } } else { - console.log(obj); return obj; } } @@ -1128,13 +1135,15 @@ })(); SwaggerHttp = (function() { + function SwaggerHttp() {} + SwaggerHttp.prototype.Shred = null; SwaggerHttp.prototype.shred = null; SwaggerHttp.prototype.content = null; - function SwaggerHttp() { + SwaggerHttp.prototype.initShred = function() { var identity, toString, _this = this; if (typeof window !== 'undefined') { @@ -1151,22 +1160,147 @@ }; if (typeof window !== 'undefined') { this.content = require("./shred/content"); - this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + return this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { parser: identity, stringify: toString }); } else { - this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + return this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { parser: identity, stringify: toString }); } - } + }; SwaggerHttp.prototype.execute = function(obj) { + if (this.isIE() || obj.useJQuery) { + return this.executeWithJQuery(obj); + } else { + return this.executeWithShred(obj); + } + }; + + SwaggerHttp.prototype.executeWithShred = function(obj) { + var cb, res, + _this = this; + if (!this.Shred) { + this.initShred(); + } + cb = obj.on; + res = { + error: function(response) { + if (obj) { + return cb.error(response); + } + }, + redirect: function(response) { + if (obj) { + return cb.redirect(response); + } + }, + 307: function(response) { + if (obj) { + return cb.redirect(response); + } + }, + response: function(raw) { + var headers, out; + if (obj) { + headers = raw._headers; + out = { + headers: headers, + url: raw.request.url, + method: raw.request.method, + status: raw.status, + data: raw.content.data + }; + return cb.response(out); + } + } + }; + if (obj) { + obj.on = res; + } return this.shred.request(obj); }; + SwaggerHttp.prototype.executeWithJQuery = function(obj) { + var beforeSend, cb, request, + _this = this; + cb = obj.on; + request = obj; + obj.type = obj.method; + obj.cache = false; + beforeSend = function(xhr) { + var key, _results; + if (obj.headers) { + _results = []; + for (key in obj.headers) { + if (key.toLowerCase() === "content-type") { + _results.push(obj.contentType = obj.headers[key]); + } else if (key.toLowerCase() === "accept") { + _results.push(obj.accepts = obj.headers[key]); + } else { + _results.push(xhr.setRequestHeader(key, obj.headers[key])); + } + } + return _results; + } + }; + obj.beforeSend = beforeSend; + obj.data = obj.body; + obj.complete = function(response, textStatus, opts) { + var headerArray, headers, i, out, _i, _j, _k, _ref, _ref1, _ref2, _ref3, _results, _results1; + headers = {}; + headerArray = response.getAllResponseHeaders().split(":"); + for (i = _i = 0, _ref = headerArray.length / 2, _ref1 = 2.; _ref1 > 0 ? _i <= _ref : _i >= _ref; i = _i += _ref1) { + headers[headerArray[i]] = headerArray[i + 1]; + } + out = { + headers: headers, + url: request.url, + method: request.method, + status: response.status, + data: response.responseText, + headers: headers + }; + if (_ref2 = response.status, __indexOf.call((function() { + _results = []; + for (_j = 200; _j <= 299; _j++){ _results.push(_j); } + return _results; + }).apply(this), _ref2) >= 0) { + cb.response(out); + } + if ((_ref3 = response.status, __indexOf.call((function() { + _results1 = []; + for (_k = 400; _k <= 599; _k++){ _results1.push(_k); } + return _results1; + }).apply(this), _ref3) >= 0) || response.status === 0) { + cb.error(out); + } + return cb.response(out); + }; + $.support.cors = true; + return $.ajax(obj); + }; + + SwaggerHttp.prototype.isIE = function() { + var isIE, nav, version; + ({ + isIE: false + }); + if (typeof navigator !== 'undefined' && navigator.userAgent) { + nav = navigator.userAgent.toLowerCase(); + if (nav.indexOf('msie') !== -1) { + version = parseInt(nav.split('msie')[1]); + if (version <= 8) { + isIE = true; + } + } + } + return isIE; + }; + return SwaggerHttp; })(); @@ -1286,6 +1420,8 @@ this.PasswordAuthorization = PasswordAuthorization; + this.SwaggerHttp = SwaggerHttp; + this.authorizations = new SwaggerAuthorizations(); }).call(this); diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index 1bd66ed1..6401bde3 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -1282,7 +1282,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; SwaggerUi.prototype.buildUrl = function(base, url) { var parts; - console.log("base is " + base); + log("base is " + base); parts = base.split("/"); base = parts[0] + "//" + parts[2]; if (url.indexOf("/") === 0) { @@ -1435,7 +1435,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; ResourceView.prototype.render = function() { var operation, _i, _len, _ref4; - console.log(this.model.description); $(this.el).html(Handlebars.templates.resource(this.model)); this.number = 0; _ref4 = this.model.operationsArray; @@ -1513,7 +1512,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; type = param.type || param.dataType; if (type.toLowerCase() === 'file') { if (!contentTypeModel.consumes) { - console.log("set content type "); + log("set content type "); contentTypeModel.consumes = 'multipart/form-data'; } } @@ -1624,7 +1623,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; OperationView.prototype.handleFileUpload = function(map, form) { var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8, _this = this; - console.log("it's a file upload"); + log("it's a file upload"); _ref5 = form.serializeArray(); for (_i = 0, _len = _ref5.length; _i < _len; _i++) { o = _ref5[_i]; @@ -1648,13 +1647,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; headerParams[param.name] = map[param.name]; } } - console.log(headerParams); + log(headerParams); _ref8 = form.find('input[type~="file"]'); for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) { el = _ref8[_l]; bodyParam.append($(el).attr('name'), el.files[0]); } - console.log(bodyParam); + log(bodyParam); this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); $(".request_url", $(this.el)).html("
" + this.invocationUrl + "
"); obj = { @@ -1690,7 +1689,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; o.content.data = data.responseText; o.getHeaders = function() { return { - "Content-Type": data.getResponseHeader("Content-Type") + "Content-Type": data.headers("Content-Type") }; }; o.request = {}; @@ -1815,16 +1814,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; return formatted; }; - OperationView.prototype.showStatus = function(data) { + OperationView.prototype.showStatus = function(response) { var code, content, contentType, headers, pre, response_body; - content = data.content.data; - headers = data.getHeaders(); + content = response.data; + headers = response.headers; contentType = headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null; if (!content) { code = $('').text("no content"); pre = $('
').append(code);
       } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
-        code = $('').text(JSON.stringify(JSON.parse(content), null, 2));
+        code = $('').text(JSON.stringify(JSON.parse(content), null, "  "));
         pre = $('
').append(code);
       } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
         code = $('').text(this.formatXml(content));
@@ -1833,16 +1832,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
         code = $('').html(content);
         pre = $('
').append(code);
       } else if (/^image\//.test(contentType)) {
-        pre = $('').attr('src', data.request.url);
+        pre = $('').attr('src', response.url);
       } else {
         code = $('').text(content);
         pre = $('
').append(code);
       }
       response_body = pre;
-      $(".request_url", $(this.el)).html("
" + data.request.url + "
"); - $(".response_code", $(this.el)).html("
" + data.status + "
"); + $(".request_url", $(this.el)).html("
" + response.url + "
"); + $(".response_code", $(this.el)).html("
" + response.status + "
"); $(".response_body", $(this.el)).html(response_body); - $(".response_headers", $(this.el)).html("
" + JSON.stringify(data.getHeaders(), null, "  ").replace(/\n/g, "
") + "
"); + $(".response_headers", $(this.el)).html("
" + JSON.stringify(response.headers, null, "  ").replace(/\n/g, "
") + "
"); $(".response", $(this.el)).slideDown(); $(".response_hider", $(this.el)).show(); $(".response_throbber", $(this.el)).hide(); diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js index 841ce67d..97385bc7 100644 --- a/dist/swagger-ui.min.js +++ b/dist/swagger-ui.min.js @@ -1 +1 @@ -$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,h="function",j=this.escapeExpression,p=this;function e(v,u){var r="",t,s;r+='\n
'+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'
\n
';s=((t=((t=v.info),t==null||t===false?t:t.description)),typeof t===h?t.apply(v):t);if(s||s===0){r+=s}r+="
\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.termsOfServiceUrl),{hash:{},inverse:p.noop,fn:p.program(2,d,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.contact),{hash:{},inverse:p.noop,fn:p.program(4,q,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.license),{hash:{},inverse:p.noop,fn:p.program(6,o,u),data:u});if(s||s===0){r+=s}r+="\n ";return r}function d(u,t){var r="",s;r+='';return r}function q(u,t){var r="",s;r+="';return r}function o(u,t){var r="",s;r+="";return r}function n(u,t){var r="",s;r+='\n , api version: ';if(s=f.apiVersion){s=s.call(u,{hash:{},data:t})}else{s=u.apiVersion;s=typeof s===h?s.apply(u):s}r+=j(s)+"\n ";return r}i+="
\n ";c=f["if"].call(m,m.info,{hash:{},inverse:p.noop,fn:p.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\n
\n
\n
    \n
\n\n
\n
\n
\n

[ base url: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]

\n
\n
\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",d,i="function",k=this.escapeExpression,r=this;function f(v,u){var s="",t;s+="\n

Implementation Notes

\n

";if(t=g.notes){t=t.call(v,{hash:{},data:u})}else{t=v.notes;t=typeof t===i?t.apply(v):t}if(t||t===0){s+=t}s+="

\n ";return s}function c(t,s){return'\n

Response Class

\n

\n
\n
\n '}function q(t,s){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function p(t,s){return"\n
\n

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "}function o(t,s){return"\n "}function e(t,s){return"\n
\n \n \n \n
\n "}j+="\n \n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,s){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);s=s||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.isFile,{hash:{},inverse:n.program(4,k,w),fn:n.program(2,l,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function l(x,w){var u="",v;u+='\n \n
\n ';return u}function k(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(7,h,w),fn:n.program(5,i,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function i(x,w){var u="",v;u+="\n \n ";return u}function h(x,w){var u="",v;u+="\n \n
\n
\n ';return u}function e(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(12,r,w),fn:n.program(10,t,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function t(x,w){var u="",v;u+="\n \n ";return u}function r(x,w){var u="",v;u+="\n \n ";return u}p+="";if(g=o.name){g=g.call(q,{hash:{},data:s})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,s),fn:n.program(1,m,s),data:s});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:s})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:s})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(g,r,p,l,w){this.compilerInfo=[4,">= 1.0.0"];p=this.merge(p,g.helpers);w=w||{};var q="",i,e,o=this,d="function",c=this.escapeExpression;function n(y,x){return" multiple='multiple'"}function m(y,x){return"\n "}function k(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.defaultValue,{hash:{},inverse:o.program(8,h,z),fn:o.program(6,j,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function j(y,x){return"\n "}function h(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.allowMultiple,{hash:{},inverse:o.program(11,v,z),fn:o.program(9,f,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function f(y,x){return"\n "}function v(y,x){return"\n \n "}function u(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.isDefault,{hash:{},inverse:o.program(16,s,z),fn:o.program(14,t,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function t(A,z){var x="",y;x+='\n \n ";return x}function s(A,z){var x="",y;x+="\n \n ";return x}q+="";if(i=p.name){i=i.call(r,{hash:{},data:w})}else{i=r.name;i=typeof i===d?i.apply(r):i}q+=c(i)+"\n\n \n\n";if(e=p.description){e=e.call(r,{hash:{},data:w})}else{e=r.description;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+="\n";if(e=p.paramType){e=e.call(r,{hash:{},data:w})}else{e=r.paramType;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+='\n';return q})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
\n
\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(f,l,e,k,j){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,f.helpers);j=j||{};var h="",c,o,g="function",i=this.escapeExpression,n=this,m=e.blockHelperMissing;function d(q,p){return" : "}h+="
\n

\n ";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+" ";o={hash:{},inverse:n.noop,fn:n.program(1,d,j),data:j};if(c=e.description){c=c.call(l,o)}else{c=l.description;c=typeof c===g?c.apply(l):c}if(!e.description){c=m.call(l,c,o)}if(c||c===0){h+=c}if(c=e.description){c=c.call(l,{hash:{},data:j})}else{c=l.description;c=typeof c===g?c.apply(l):c}if(c||c===0){h+=c}h+="\n

\n \n
\n\n";return h})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='
\n\n
\n\n
\n
\n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
\n\n
\n
';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
\n \n
\n
\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('
')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){return B.onLoadFailure(C)};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerApi(this.options);this.api.build();return this.api};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(B,A){var C;console.log("base is "+B);C=B.split("/");B=C[0]+"//"+C[2];if(A.indexOf("/")===0){return B+A}else{return B+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){v(z,y);function z(){g=z.__super__.constructor.apply(this,arguments);return g}z.prototype.initialize=function(){};z.prototype.render=function(){var C,B,A,D;$(this.el).html(Handlebars.templates.main(this.model));D=this.model.apisArray;for(B=0,A=D.length;B0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(Q,I){var M,H,C,N,L,K,J,G,E,D,P,T,S,R,F,B,A,U,O=this;console.log("it's a file upload");F=I.serializeArray();for(J=0,P=F.length;J0){Q[N.name]=N.value}}M=new FormData();B=this.model.parameters;for(G=0,T=B.length;G"+this.invocationUrl+"
");L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(W,X,V){return O.showErrorStatus(O.wrap(W),O)},success:function(V){return O.showResponse(V,O)},complete:function(V){return O.showCompleteStatus(O.wrap(V),O)}};if(window.authorizations){window.authorizations.apply(L)}jQuery.ajax(L);return false};y.prototype.wrap=function(A){var B,C=this;B={};B.content={};B.content.data=A.responseText;B.getHeaders=function(){return{"Content-Type":A.getResponseHeader("Content-Type")}};B.request={};B.request.url=this.invocationUrl;B.status=A.status;return B};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?XY;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E").text("no content");E=$('
').append(C)}else{if(G==="application/json"||/\+json$/.test(G)){C=$("").text(JSON.stringify(JSON.parse(B),null,2));E=$('
').append(C)}else{if(G==="application/xml"||/\+xml$/.test(G)){C=$("").text(this.formatXml(B));E=$('
').append(C)}else{if(G==="text/html"){C=$("").html(B);E=$('
').append(C)}else{if(/^image\//.test(G)){E=$("").attr("src",D.request.url)}else{C=$("").text(B);E=$('
').append(C)}}}}}A=E;$(".request_url",$(this.el)).html("
"+D.request.url+"
");$(".response_code",$(this.el)).html("
"+D.status+"
");$(".response_body",$(this.el)).html(A);$(".response_headers",$(this.el)).html("
"+JSON.stringify(D.getHeaders(),null,"  ").replace(/\n/g,"
")+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){};y.prototype.render=function(){var G,A,C,F,B,H,E,D;D=this.model.type||this.model.dataType;if(this.model.paramType==="body"){this.model.isBody=true}if(D.toLowerCase()==="file"){this.model.isFile=true}E=this.template();$(this.el).html(E(this.model));B={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){H=new i({model:B,tagName:"div"});$(".model-signature",$(this.el)).append(H.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}A=false;if(this.model.isBody){A=true}G={isParam:A};G.consumes=this.model.consumes;if(A){C=new l({model:G});$(".parameter-content-type",$(this.el)).append(C.render().el)}else{F=new m({model:G});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this); \ No newline at end of file +$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,h="function",j=this.escapeExpression,p=this;function e(v,u){var r="",t,s;r+='\n
'+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'
\n
';s=((t=((t=v.info),t==null||t===false?t:t.description)),typeof t===h?t.apply(v):t);if(s||s===0){r+=s}r+="
\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.termsOfServiceUrl),{hash:{},inverse:p.noop,fn:p.program(2,d,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.contact),{hash:{},inverse:p.noop,fn:p.program(4,q,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.license),{hash:{},inverse:p.noop,fn:p.program(6,o,u),data:u});if(s||s===0){r+=s}r+="\n ";return r}function d(u,t){var r="",s;r+='';return r}function q(u,t){var r="",s;r+="';return r}function o(u,t){var r="",s;r+="";return r}function n(u,t){var r="",s;r+='\n , api version: ';if(s=f.apiVersion){s=s.call(u,{hash:{},data:t})}else{s=u.apiVersion;s=typeof s===h?s.apply(u):s}r+=j(s)+"\n ";return r}i+="
\n ";c=f["if"].call(m,m.info,{hash:{},inverse:p.noop,fn:p.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\n
\n
\n
    \n
\n\n
\n
\n
\n

[ base url: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]

\n
\n
\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,n,g,m,l){this.compilerInfo=[4,">= 1.0.0"];g=this.merge(g,h.helpers);l=l||{};var j="",d,i="function",k=this.escapeExpression,r=this;function f(v,u){var s="",t;s+="\n

Implementation Notes

\n

";if(t=g.notes){t=t.call(v,{hash:{},data:u})}else{t=v.notes;t=typeof t===i?t.apply(v):t}if(t||t===0){s+=t}s+="

\n ";return s}function c(t,s){return'\n

Response Class

\n

\n
\n
\n '}function q(t,s){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function p(t,s){return"\n
\n

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "}function o(t,s){return"\n "}function e(t,s){return"\n
\n \n \n \n
\n "}j+="\n \n";return j})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,s){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);s=s||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.isFile,{hash:{},inverse:n.program(4,k,w),fn:n.program(2,l,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function l(x,w){var u="",v;u+='\n \n
\n ';return u}function k(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(7,h,w),fn:n.program(5,i,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function i(x,w){var u="",v;u+="\n \n ";return u}function h(x,w){var u="",v;u+="\n \n
\n
\n ';return u}function e(x,w){var u="",v;u+="\n ";v=o["if"].call(x,x.defaultValue,{hash:{},inverse:n.program(12,r,w),fn:n.program(10,t,w),data:w});if(v||v===0){u+=v}u+="\n ";return u}function t(x,w){var u="",v;u+="\n \n ";return u}function r(x,w){var u="",v;u+="\n \n ";return u}p+="";if(g=o.name){g=g.call(q,{hash:{},data:s})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,s),fn:n.program(1,m,s),data:s});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:s})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:s})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(g,r,p,l,w){this.compilerInfo=[4,">= 1.0.0"];p=this.merge(p,g.helpers);w=w||{};var q="",i,e,o=this,d="function",c=this.escapeExpression;function n(y,x){return" multiple='multiple'"}function m(y,x){return"\n "}function k(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.defaultValue,{hash:{},inverse:o.program(8,h,z),fn:o.program(6,j,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function j(y,x){return"\n "}function h(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.allowMultiple,{hash:{},inverse:o.program(11,v,z),fn:o.program(9,f,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function f(y,x){return"\n "}function v(y,x){return"\n \n "}function u(A,z){var x="",y;x+="\n ";y=p["if"].call(A,A.isDefault,{hash:{},inverse:o.program(16,s,z),fn:o.program(14,t,z),data:z});if(y||y===0){x+=y}x+="\n ";return x}function t(A,z){var x="",y;x+='\n \n ";return x}function s(A,z){var x="",y;x+="\n \n ";return x}q+="";if(i=p.name){i=i.call(r,{hash:{},data:w})}else{i=r.name;i=typeof i===d?i.apply(r):i}q+=c(i)+"\n\n \n\n";if(e=p.description){e=e.call(r,{hash:{},data:w})}else{e=r.description;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+="\n";if(e=p.paramType){e=e.call(r,{hash:{},data:w})}else{e=r.paramType;e=typeof e===d?e.apply(r):e}if(e||e===0){q+=e}q+='\n';return q})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
\n
\n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(f,l,e,k,j){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,f.helpers);j=j||{};var h="",c,o,g="function",i=this.escapeExpression,n=this,m=e.blockHelperMissing;function d(q,p){return" : "}h+="
\n

\n ";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+" ";o={hash:{},inverse:n.noop,fn:n.program(1,d,j),data:j};if(c=e.description){c=c.call(l,o)}else{c=l.description;c=typeof c===g?c.apply(l):c}if(!e.description){c=m.call(l,c,o)}if(c||c===0){h+=c}if(c=e.description){c=c.call(l,{hash:{},data:j})}else{c=l.description;c=typeof c===g?c.apply(l):c}if(c||c===0){h+=c}h+="\n

\n \n
\n\n";return h})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='
\n\n
\n\n
\n
\n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
\n\n
\n
';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
\n \n
\n
\n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('
')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){return B.onLoadFailure(C)};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerApi(this.options);this.api.build();return this.api};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}if(this.options.onComplete){this.options.onComplete(this.api,this)}return setTimeout(function(){return Docs.shebang()},400)};y.prototype.buildUrl=function(B,A){var C;log("base is "+B);C=B.split("/");B=C[0]+"//"+C[2];if(A.indexOf("/")===0){return B+A}else{return B+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.prototype.events={"click #show-pet-store-icon":"showPetStore","click #show-wordnik-dev-icon":"showWordnikDev","click #explore":"showCustom","keyup #input_baseUrl":"showCustomOnKeyup","keyup #input_apiKey":"showCustomOnKeyup"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){v(z,y);function z(){g=z.__super__.constructor.apply(this,arguments);return g}z.prototype.initialize=function(){};z.prototype.render=function(){var C,B,A,D;$(this.el).html(Handlebars.templates.main(this.model));D=this.model.apisArray;for(B=0,A=D.length;B0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(Q,I){var M,H,C,N,L,K,J,G,E,D,P,T,S,R,F,B,A,U,O=this;log("it's a file upload");F=I.serializeArray();for(J=0,P=F.length;J0){Q[N.name]=N.value}}M=new FormData();B=this.model.parameters;for(G=0,T=B.length;G"+this.invocationUrl+"
");L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(W,X,V){return O.showErrorStatus(O.wrap(W),O)},success:function(V){return O.showResponse(V,O)},complete:function(V){return O.showCompleteStatus(O.wrap(V),O)}};if(window.authorizations){window.authorizations.apply(L)}jQuery.ajax(L);return false};y.prototype.wrap=function(A){var B,C=this;B={};B.content={};B.content.data=A.responseText;B.getHeaders=function(){return{"Content-Type":A.headers("Content-Type")}};B.request={};B.request.url=this.invocationUrl;B.status=A.status;return B};y.prototype.getSelectedValue=function(A){var D,C,F,B,E;if(!A.multiple){return A.value}else{C=[];E=A.options;for(F=0,B=E.length;F0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"single->single":0,"single->closing":-1,"single->opening":0,"single->other":0,"closing->single":0,"closing->closing":-1,"closing->opening":0,"closing->other":0,"opening->single":1,"opening->closing":0,"opening->opening":1,"opening->other":1,"other->single":0,"other->closing":-1,"other->opening":0,"other->other":0};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?XY;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E").text("no content");E=$('
').append(D)}else{if(G==="application/json"||/\+json$/.test(G)){D=$("").text(JSON.stringify(JSON.parse(C),null,"  "));E=$('
').append(D)}else{if(G==="application/xml"||/\+xml$/.test(G)){D=$("").text(this.formatXml(C));E=$('
').append(D)}else{if(G==="text/html"){D=$("").html(C);E=$('
').append(D)}else{if(/^image\//.test(G)){E=$("").attr("src",A.url)}else{D=$("").text(C);E=$('
').append(D)}}}}}B=E;$(".request_url",$(this.el)).html("
"+A.url+"
");$(".response_code",$(this.el)).html("
"+A.status+"
");$(".response_body",$(this.el)).html(B);$(".response_headers",$(this.el)).html("
"+JSON.stringify(A.headers,null,"  ").replace(/\n/g,"
")+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){};y.prototype.render=function(){var G,A,C,F,B,H,E,D;D=this.model.type||this.model.dataType;if(this.model.paramType==="body"){this.model.isBody=true}if(D.toLowerCase()==="file"){this.model.isFile=true}E=this.template();$(this.el).html(E(this.model));B={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){H=new i({model:B,tagName:"div"});$(".model-signature",$(this.el)).append(H.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}A=false;if(this.model.isBody){A=true}G={isParam:A};G.consumes=this.model.consumes;if(A){C=new l({model:G});$(".parameter-content-type",$(this.el)).append(C.render().el)}else{F=new m({model:G});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.prototype.template=function(){if(this.model.isList){return Handlebars.templates.param_list}else{if(this.options.readOnly){if(this.model.required){return Handlebars.templates.param_readonly_required}else{return Handlebars.templates.param_readonly}}else{if(this.model.required){return Handlebars.templates.param_required}else{return Handlebars.templates.param}}}};return y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this); \ No newline at end of file diff --git a/lib/swagger.js b/lib/swagger.js index bbdca4f6..117e0c83 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -1,7 +1,8 @@ // Generated by CoffeeScript 1.6.3 (function() { var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; SwaggerApi = (function() { SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json"; @@ -16,6 +17,8 @@ SwaggerApi.prototype.info = null; + SwaggerApi.prototype.useJQuery = null; + function SwaggerApi(url, options) { if (options == null) { options = {}; @@ -47,6 +50,7 @@ _this = this; this.progress('fetching resource list: ' + this.url); obj = { + useJQuery: this.useJQuery, url: this.url, method: "get", headers: {}, @@ -62,14 +66,14 @@ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url); } }, - response: function(rawResponse) { - var response; - response = JSON.parse(rawResponse.content.data); - _this.swaggerVersion = response.swaggerVersion; + response: function(response) { + var responseObj; + responseObj = JSON.parse(response.data); + _this.swaggerVersion = responseObj.swaggerVersion; if (_this.swaggerVersion === "1.2") { - return _this.buildFromSpec(response); + return _this.buildFromSpec(responseObj); } else { - return _this.buildFrom1_1Spec(response); + return _this.buildFrom1_1Spec(responseObj); } } } @@ -139,7 +143,7 @@ SwaggerApi.prototype.buildFrom1_1Spec = function(response) { var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; - console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info"); + log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info"); if (response.apiVersion != null) { this.apiVersion = response.apiVersion; } @@ -241,15 +245,15 @@ _ref = this.apis; for (resource_name in _ref) { resource = _ref[resource_name]; - console.log(resource_name); + log(resource_name); _ref1 = resource.operations; for (operation_name in _ref1) { operation = _ref1[operation_name]; - console.log(" " + operation.nickname); + log(" " + operation.nickname); _ref2 = operation.parameters; for (_i = 0, _len = _ref2.length; _i < _len; _i++) { parameter = _ref2[_i]; - console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); } } } @@ -283,6 +287,7 @@ this.operationsArray = []; this.modelsArray = []; this.models = {}; + this.rawModels = {}; if ((resourceObj.apis != null) && (this.api.resourcePath != null)) { this.addApiDeclaration(resourceObj); } else { @@ -298,15 +303,16 @@ obj = { url: this.url, method: "get", + useJQuery: this.useJQuery, headers: {}, on: { error: function(response) { return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")"); }, - response: function(rawResponse) { - var response; - response = JSON.parse(rawResponse.content.data); - return _this.addApiDeclaration(response); + response: function(response) { + var responseObj; + responseObj = JSON.parse(response.data); + return _this.addApiDeclaration(responseObj); } } }; @@ -372,6 +378,7 @@ swaggerModel = new SwaggerModel(modelName, models[modelName]); this.modelsArray.push(swaggerModel); this.models[modelName] = swaggerModel; + this.rawModels[modelName] = models[modelName]; } } _ref = this.modelsArray; @@ -522,7 +529,7 @@ _ref1 = this.properties; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { prop = _ref1[_j]; - if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) { + if ((prop.refModel != null) && (modelsToIgnore[prop.refModel] !== 'undefined') === -1) { returnVal = returnVal + ('
' + prop.refModel.getMockSignature(modelsToIgnore)); } } @@ -581,7 +588,7 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) { var result; - if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) { + if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) { result = this.refModel.createJSONSample(modelsToIgnore); } else { if (this.isCollection) { @@ -661,7 +668,7 @@ parameter = _ref1[_i]; parameter.name = parameter.name || parameter.type || parameter.dataType; type = parameter.type || parameter.dataType; - if (typeof type !== 'undefined' && type.toLowerCase() === 'boolean') { + if (type.toLowerCase() === 'boolean') { parameter.allowableValues = {}; parameter.allowableValues.values = ["true", "false"]; } @@ -776,19 +783,19 @@ } if (error == null) { error = function(xhr, textStatus, error) { - return console.log(xhr, textStatus, error); + return log(xhr, textStatus, error); }; } if (callback == null) { - callback = function(data) { + callback = function(response) { var content; content = null; - if (data.content != null) { - content = data.content.data; + if (response != null) { + content = response.data; } else { content = "no data"; } - return console.log("default callback: " + content); + return log("default callback: " + content); }; } params = {}; @@ -990,7 +997,7 @@ _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { param = _ref[_i]; - if (typeof type !== 'undefined' && type.toLowerCase() === "file") { + if (type.toLowerCase() === "file") { _results.push(param); } } @@ -1005,8 +1012,8 @@ } } if (requestContentType && this.operation.consumes) { - if (this.operation.consumes.indexOf(requestContentType) === -1) { - console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes)); + if (this.operation.consumes[requestContentType] === 'undefined') { + log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes)); if (this.requestContentType === null) { requestContentType = this.operation.consumes[0]; } @@ -1023,8 +1030,8 @@ responseContentType = null; } if (responseContentType && this.operation.produces) { - if (this.operation.produces.indexOf(responseContentType) === -1) { - console.log("server can't produce " + responseContentType); + if (this.operation.produces[responseContentType] === 'undefined') { + log("server can't produce " + responseContentType); } } if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) { @@ -1073,6 +1080,7 @@ method: this.type, headers: myHeaders, body: body, + useJQuery: this.useJQuery, on: { error: function(response) { return _this.errorCallback(response, _this.opts.parent); @@ -1102,7 +1110,6 @@ obj.canceled = true; } } else { - console.log(obj); return obj; } } @@ -1128,13 +1135,15 @@ })(); SwaggerHttp = (function() { + function SwaggerHttp() {} + SwaggerHttp.prototype.Shred = null; SwaggerHttp.prototype.shred = null; SwaggerHttp.prototype.content = null; - function SwaggerHttp() { + SwaggerHttp.prototype.initShred = function() { var identity, toString, _this = this; if (typeof window !== 'undefined') { @@ -1151,22 +1160,147 @@ }; if (typeof window !== 'undefined') { this.content = require("./shred/content"); - this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + return this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { parser: identity, stringify: toString }); } else { - this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + return this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { parser: identity, stringify: toString }); } - } + }; SwaggerHttp.prototype.execute = function(obj) { + if (this.isIE() || obj.useJQuery) { + return this.executeWithJQuery(obj); + } else { + return this.executeWithShred(obj); + } + }; + + SwaggerHttp.prototype.executeWithShred = function(obj) { + var cb, res, + _this = this; + if (!this.Shred) { + this.initShred(); + } + cb = obj.on; + res = { + error: function(response) { + if (obj) { + return cb.error(response); + } + }, + redirect: function(response) { + if (obj) { + return cb.redirect(response); + } + }, + 307: function(response) { + if (obj) { + return cb.redirect(response); + } + }, + response: function(raw) { + var headers, out; + if (obj) { + headers = raw._headers; + out = { + headers: headers, + url: raw.request.url, + method: raw.request.method, + status: raw.status, + data: raw.content.data + }; + return cb.response(out); + } + } + }; + if (obj) { + obj.on = res; + } return this.shred.request(obj); }; + SwaggerHttp.prototype.executeWithJQuery = function(obj) { + var beforeSend, cb, request, + _this = this; + cb = obj.on; + request = obj; + obj.type = obj.method; + obj.cache = false; + beforeSend = function(xhr) { + var key, _results; + if (obj.headers) { + _results = []; + for (key in obj.headers) { + if (key.toLowerCase() === "content-type") { + _results.push(obj.contentType = obj.headers[key]); + } else if (key.toLowerCase() === "accept") { + _results.push(obj.accepts = obj.headers[key]); + } else { + _results.push(xhr.setRequestHeader(key, obj.headers[key])); + } + } + return _results; + } + }; + obj.beforeSend = beforeSend; + obj.data = obj.body; + obj.complete = function(response, textStatus, opts) { + var headerArray, headers, i, out, _i, _j, _k, _ref, _ref1, _ref2, _ref3, _results, _results1; + headers = {}; + headerArray = response.getAllResponseHeaders().split(":"); + for (i = _i = 0, _ref = headerArray.length / 2, _ref1 = 2.; _ref1 > 0 ? _i <= _ref : _i >= _ref; i = _i += _ref1) { + headers[headerArray[i]] = headerArray[i + 1]; + } + out = { + headers: headers, + url: request.url, + method: request.method, + status: response.status, + data: response.responseText, + headers: headers + }; + if (_ref2 = response.status, __indexOf.call((function() { + _results = []; + for (_j = 200; _j <= 299; _j++){ _results.push(_j); } + return _results; + }).apply(this), _ref2) >= 0) { + cb.response(out); + } + if ((_ref3 = response.status, __indexOf.call((function() { + _results1 = []; + for (_k = 400; _k <= 599; _k++){ _results1.push(_k); } + return _results1; + }).apply(this), _ref3) >= 0) || response.status === 0) { + cb.error(out); + } + return cb.response(out); + }; + $.support.cors = true; + return $.ajax(obj); + }; + + SwaggerHttp.prototype.isIE = function() { + var isIE, nav, version; + ({ + isIE: false + }); + if (typeof navigator !== 'undefined' && navigator.userAgent) { + nav = navigator.userAgent.toLowerCase(); + if (nav.indexOf('msie') !== -1) { + version = parseInt(nav.split('msie')[1]); + if (version <= 8) { + isIE = true; + } + } + } + return isIE; + }; + return SwaggerHttp; })(); @@ -1286,6 +1420,8 @@ this.PasswordAuthorization = PasswordAuthorization; + this.SwaggerHttp = SwaggerHttp; + this.authorizations = new SwaggerAuthorizations(); }).call(this); diff --git a/package.json b/package.json index a1a1da44..650e2b25 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "readmeFilename": "README.md", "dependencies": { "coffee-script": "~1.5.0", - "swagger-client": "2.0.8", + "swagger-client": "2.0.9", "handlebars": "~1.0.10", "less": "~1.4.2" } diff --git a/src/main/coffeescript/SwaggerUi.coffee b/src/main/coffeescript/SwaggerUi.coffee index 9bb40fd0..1029926b 100644 --- a/src/main/coffeescript/SwaggerUi.coffee +++ b/src/main/coffeescript/SwaggerUi.coffee @@ -68,7 +68,7 @@ class SwaggerUi extends Backbone.Router ) buildUrl: (base, url) -> - console.log "base is " + base + log "base is " + base parts = base.split("/") base = parts[0] + "//" + parts[2] if url.indexOf("/") is 0 diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee index 19594c18..c3d49b68 100644 --- a/src/main/coffeescript/view/OperationView.coffee +++ b/src/main/coffeescript/view/OperationView.coffee @@ -37,7 +37,7 @@ class OperationView extends Backbone.View type = param.type || param.dataType if type.toLowerCase() == 'file' if !contentTypeModel.consumes - console.log "set content type " + log "set content type " contentTypeModel.consumes = 'multipart/form-data' responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel}) @@ -110,7 +110,7 @@ class OperationView extends Backbone.View parent.showCompleteStatus response handleFileUpload: (map, form) -> - console.log "it's a file upload" + log "it's a file upload" for o in form.serializeArray() if(o.value? && jQuery.trim(o.value).length > 0) map[o.name] = o.value @@ -129,13 +129,13 @@ class OperationView extends Backbone.View if param.paramType is 'header' headerParams[param.name] = map[param.name] - console.log headerParams + log headerParams # add files for el in form.find('input[type~="file"]') bodyParam.append($(el).attr('name'), el.files[0]) - console.log(bodyParam) + log(bodyParam) @invocationUrl = if @model.supportHeaderParams() @@ -174,7 +174,7 @@ class OperationView extends Backbone.View o = {} o.content = {} o.content.data = data.responseText - o.getHeaders = () => {"Content-Type": data.getResponseHeader("Content-Type")} + o.getHeaders = () => {"Content-Type": data.headers("Content-Type")} o.request = {} o.request.url = @invocationUrl o.status = data.status @@ -271,9 +271,9 @@ class OperationView extends Backbone.View # puts the response data in UI - showStatus: (data) -> - content = data.content.data - headers = data.getHeaders() + showStatus: (response) -> + content = response.data + headers = response.headers # if server is nice, and sends content-type back, we can use it contentType = if headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null @@ -282,7 +282,7 @@ class OperationView extends Backbone.View code = $('').text("no content") pre = $('
').append(code)
     else if contentType is "application/json" || /\+json$/.test(contentType)
-      code = $('').text(JSON.stringify(JSON.parse(content), null, 2))
+      code = $('').text(JSON.stringify(JSON.parse(content), null, "  "))
       pre = $('
').append(code)
     else if contentType is "application/xml" || /\+xml$/.test(contentType)
       code = $('').text(@formatXml(content))
@@ -291,17 +291,17 @@ class OperationView extends Backbone.View
       code = $('').html(content)
       pre = $('
').append(code)
     else if /^image\//.test(contentType)
-      pre = $('').attr('src',data.request.url)
+      pre = $('').attr('src',response.url)
     else
       # don't know what to render!
       code = $('').text(content)
       pre = $('
').append(code)
 
     response_body = pre
-    $(".request_url", $(@el)).html "
" + data.request.url + "
" - $(".response_code", $(@el)).html "
" + data.status + "
" + $(".request_url", $(@el)).html "
" + response.url + "
" + $(".response_code", $(@el)).html "
" + response.status + "
" $(".response_body", $(@el)).html response_body - $(".response_headers", $(@el)).html "
" + JSON.stringify(data.getHeaders(), null, "  ").replace(/\n/g, "
") + "
" + $(".response_headers", $(@el)).html "
" + JSON.stringify(response.headers, null, "  ").replace(/\n/g, "
") + "
" $(".response", $(@el)).slideDown() $(".response_hider", $(@el)).show() $(".response_throbber", $(@el)).hide() diff --git a/src/main/coffeescript/view/ResourceView.coffee b/src/main/coffeescript/view/ResourceView.coffee index 936e325c..ab9d7a3d 100644 --- a/src/main/coffeescript/view/ResourceView.coffee +++ b/src/main/coffeescript/view/ResourceView.coffee @@ -2,7 +2,6 @@ class ResourceView extends Backbone.View initialize: -> render: -> - console.log @model.description $(@el).html(Handlebars.templates.resource(@model)) @number = 0 diff --git a/src/main/html/index.html b/src/main/html/index.html index 2f092c1f..44cc3717 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -2,7 +2,7 @@ Swagger UI - + @@ -23,25 +23,20 @@ dom_id: "swagger-ui-container", supportedSubmitMethods: ['get', 'post', 'put', 'delete'], onComplete: function(swaggerApi, swaggerUi){ - if(console) { - console.log("Loaded SwaggerUI") - } + log("Loaded SwaggerUI") $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); }, onFailure: function(data) { - if(console) { - console.log("Unable to Load SwaggerUI"); - console.log(data); - } + log("Unable to Load SwaggerUI"); }, docExpansion: "none" }); $('#input_apiKey').change(function() { var key = $('#input_apiKey')[0].value; - console.log("key: " + key); + log("key: " + key); if(key && key.trim() != "") { - console.log("added key " + key); + log("added key " + key); window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query")); } })