diff --git a/dist/index.html b/dist/index.html index 5f9d8523..b09bc7d3 100644 --- a/dist/index.html +++ b/dist/index.html @@ -45,6 +45,7 @@ var key = $('#input_apiKey')[0].value; console.log("key: " + key); if(key && key.trim() != "") { + console.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 177a109d..07571e5b 100644 --- a/dist/lib/swagger.js +++ b/dist/lib/swagger.js @@ -38,6 +38,7 @@ var obj, _this = this; this.progress('fetching resource list: ' + this.discoveryUrl); + console.log('getting ' + this.discoveryUrl); obj = { url: this.discoveryUrl, method: "get", @@ -79,7 +80,8 @@ } } }; - return new SwaggerHttp().execute(obj); + new SwaggerHttp().execute(obj); + return this; }; SwaggerApi.prototype.selfReflect = function() { @@ -519,6 +521,9 @@ this.resource[this.nickname] = function(args, callback, error) { return _this["do"](args, callback, error); }; + this.resource[this.nickname].help = function() { + return _this.help(); + }; } SwaggerOperation.prototype.isListType = function(dataType) { @@ -555,18 +560,25 @@ } }; - SwaggerOperation.prototype["do"] = function(args, callback, error) { - var key, param, params, possibleParams, requestContentType, responseContentType, value; + SwaggerOperation.prototype["do"] = function(args, opts, callback, error) { + var key, param, params, possibleParams, req, requestContentType, responseContentType, value; if (args == null) { args = {}; } + if (opts == null) { + opts = {}; + } requestContentType = null; responseContentType = null; if ((typeof args) === "function") { - error = callback; + error = opts; callback = args; args = {}; } + if ((typeof opts) === "function") { + error = callback; + callback = opts; + } if (error == null) { error = function(xhr, textStatus, error) { return console.log(xhr, textStatus, error); @@ -574,16 +586,17 @@ } if (callback == null) { callback = function(data) { - return console.log("default callback: " + data); + var content; + content = null; + if (data.content != null) { + content = data.content.data; + } else { + content = "no data"; + } + return console.log("default callback: " + content); }; } params = {}; - if (args.requestContentType) { - requestContentType = args.requestContentType; - } - if (args.responseContentType) { - responseContentType = args.responseContentType; - } if (args.headers != null) { params.headers = args.headers; delete args.headers; @@ -612,11 +625,12 @@ } } } - if (args.mock != null) { - params.mock = args["mock"]; + req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this); + if (opts.mock != null) { + return req; + } else { + return true; } - params["parent"] = args["parent"]; - return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this); }; SwaggerOperation.prototype.pathJson = function() { @@ -716,14 +730,13 @@ SwaggerRequest = (function() { - function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) { - var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values, + function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) { + var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values, _this = this; this.type = type; this.url = url; this.params = params; - this.requestContentType = requestContentType; - this.responseContentType = responseContentType; + this.opts = opts; this.successCallback = successCallback; this.errorCallback = errorCallback; this.operation = operation; @@ -750,8 +763,8 @@ parent = params["parent"]; requestContentType = "application/json"; if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) { - if (this.requestContentType) { - requestContentType = this.requestContentType; + if (this.opts.requestContentType) { + requestContentType = this.opts.requestContentType; } } else { if (((function() { @@ -777,14 +790,12 @@ if (this.requestContentType === null) { requestContentType = this.operation.consumes[0]; } - } else { - console.log("it's ok to send " + requestContentType); } } responseContentType = null; if (this.type === "POST" || this.type === "GET") { - if (this.responseContentType) { - responseContentType = this.responseContentType; + if (this.opts.responseContentType) { + responseContentType = this.opts.responseContentType; } else { responseContentType = "application/json"; } @@ -794,12 +805,9 @@ if (responseContentType && this.operation.produces) { if (this.operation.produces.indexOf(responseContentType) === -1) { console.log("server can't produce " + responseContentType); - } else { - console.log("get ready for " + responseContentType); } } if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) { - console.log("pulling fields"); fields = {}; possibleParams = (function() { var _i, _len, _ref, _results; @@ -813,7 +821,6 @@ } return _results; }).call(this); - console.log(possibleParams); values = {}; for (key in possibleParams) { value = possibleParams[key]; @@ -845,16 +852,16 @@ body: body, on: { error: function(response) { - return _this.errorCallback(response, _this.params["parent"]); + return _this.errorCallback(response, _this.opts.parent); }, redirect: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); }, 307: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); }, response: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); } } }; @@ -865,9 +872,10 @@ e = exports; } e.authorizations.apply(obj); - if (params.mock == null) { + if (opts.mock == null) { new SwaggerHttp().execute(obj); } else { + console.log(obj); return obj; } } @@ -894,33 +902,42 @@ SwaggerHttp = (function() { + SwaggerHttp.prototype.Shred = null; + SwaggerHttp.prototype.shred = null; - function SwaggerHttp() { - var Shred; - Shred = null; - if (typeof window !== 'undefined') { - Shred = require("./shred"); - } else { - Shred = require("shred"); - } - this.shred = new Shred(); - } + SwaggerHttp.prototype.content = null; - SwaggerHttp.prototype.execute = function(obj) { - var Content, identity, toString, + function SwaggerHttp() { + var identity, toString, _this = this; - Content = require("./shred/content"); + if (typeof window !== 'undefined') { + this.Shred = require("./shred"); + } else { + this.Shred = require("shred"); + } + this.shred = new this.Shred(); identity = function(x) { return x; }; toString = function(x) { return x.toString; }; - Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { - parser: identity, - stringify: toString - }); + if (typeof window !== 'undefined') { + this.content = require("./shred/content"); + 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"], { + parser: identity, + stringify: toString + }); + } + } + + SwaggerHttp.prototype.execute = function(obj) { return this.shred.request(obj); }; @@ -972,6 +989,7 @@ ApiKeyAuthorization.prototype.apply = function(obj) { if (this.type === "query") { + console.log(this.value); if (obj.url.indexOf('?') > 0) { obj.url = obj.url + "&" + this.name + "=" + this.value; } else { @@ -997,8 +1015,6 @@ this.SwaggerModelProperty = SwaggerModelProperty; - this.SwaggerAuthorizations = new SwaggerAuthorizations(); - this.ApiKeyAuthorization = ApiKeyAuthorization; this.authorizations = new SwaggerAuthorizations(); diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js index f6e604c8..b161d30d 100644 --- a/dist/swagger-ui.js +++ b/dist/swagger-ui.js @@ -1183,7 +1183,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da stack1 = foundHelper || depth0.name; if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "');\">/"; + buffer += escapeExpression(stack1) + "');\">"; foundHelper = helpers.name; stack1 = foundHelper || depth0.name; if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } @@ -1385,7 +1385,6 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials SwaggerUi.prototype.updateSwaggerUi = function(data) { this.options.discoveryUrl = data.discoveryUrl; - this.options.apiKey = data.apiKey; return this.load(); }; @@ -1394,7 +1393,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials if ((_ref = this.mainView) != null) { _ref.clear(); } - this.headerView.update(this.options.discoveryUrl, this.options.apiKey); + this.headerView.update(this.options.discoveryUrl); return this.api = new SwaggerApi(this.options); }; @@ -1470,15 +1469,13 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials HeaderView.prototype.showPetStore = function(e) { return this.trigger('update-swagger-ui', { - discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json", - apiKey: "special-key" + discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json" }); }; HeaderView.prototype.showWordnikDev = function(e) { return this.trigger('update-swagger-ui', { - discoveryUrl: "http://api.wordnik.com/v4/resources.json", - apiKey: "" + discoveryUrl: "http://api.wordnik.com/v4/resources.json" }); }; @@ -1675,7 +1672,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }; OperationView.prototype.submitOperation = function(e) { - var error_free, form, map, o, _i, _len, _ref; + var error_free, form, map, o, opts, _i, _len, _ref; if (e != null) { e.preventDefault(); } @@ -1695,7 +1692,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials } }); if (error_free) { - map = { + map = {}; + opts = { parent: this }; _ref = form.serializeArray(); @@ -1706,9 +1704,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials } } console.log(map); - map["responseContentType"] = $("div select[name=responseContentType]", $(this.el)).val(); - map["requestContentType"] = $("div select[name=parameterContentType]", $(this.el)).val(); - return this.model["do"](map, this.showCompleteStatus, this.showErrorStatus, this); + opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val(); + opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val(); + return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this); } }; diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js index 9362cb88..ce29871b 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,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , api version: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n
\n \n\n
\n
\n
\n

[ base url: ";j=e.basePath;c=j||p.basePath;if(typeof c===g){c=c.call(p,{hash:{}})}else{if(c===h){c=o.call(p,"basePath",{hash:{}})}}k+=l(c)+"\n ";j=e.apiVersion;c=j||p.apiVersion;r=e["if"];i=q.program(1,d,m);i.hash={};i.fn=i;i.inverse=q.noop;c=r.call(p,c,i);if(c||c===0){k+=c}k+="]

\n
\n
\n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,w){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(A,z){var x="",y;x+="\n

Implementation Notes

\n

";i=s.notes;y=i||A.notes;if(typeof y===e){y=y.call(A,{hash:{}})}else{if(y===c){y=r.call(A,"notes",{hash:{}})}}if(y||y===0){x+=y}x+="

\n ";return x}function n(y,x){return'\n

Response Class

\n

\n
\n
\n '}function l(y,x){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function k(y,x){return"\n
\n

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "}function f(y,x){return"\n "}function v(y,x){return"\n
\n \n \n \n
\n "}t+="\n \n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n \n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n \n ";return z}function k(C,B){var z="",A;z+="\n \n
\n
\n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n \n ";return z}function w(C,B){var z="",A;z+="\n \n ";return z}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n \n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n \n ";return y}function w(B,A){var y="",z;y+="\n \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+"\n\n \n\n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+="\n";j=t.paramType;k=j||v.paramType;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"paramType",{hash:{}})}}if(k||k===0){u+=k}u+='\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+"\n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n\n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+="\n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+='\n\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+"\n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n\n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+="\n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+='\n\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n \n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n \n ";return B}function k(E,D){var B="",C;B+="\n \n
\n
\n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n \n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n \n ";return B}function w(E,D){var B="",C;B+="\n \n ";return B}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n\n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.consumes;v=k||x.consumes;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='
\n\n
\n\n
\n
\n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n
\n\n
\n
';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'
\n \n
\n
\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+"\n";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+="\n\n";return i})})();(function(){var g,c,i,d,m,f,k,a,l,j,b,h={}.hasOwnProperty,e=function(q,o){for(var n in o){if(h.call(o,n)){q[n]=o[n]}}function p(){this.constructor=q}p.prototype=o.prototype;q.prototype=new p();q.__super__=o.prototype;return q};b=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.dom_id="swagger_ui";n.prototype.options=null;n.prototype.api=null;n.prototype.headerView=null;n.prototype.mainView=null;n.prototype.initialize=function(p){var q=this;if(p==null){p={}}if(p.dom_id!=null){this.dom_id=p.dom_id;delete p.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=p;this.options.success=function(){return q.render()};this.options.progress=function(r){return q.showMessage(r)};this.options.failure=function(r){return q.onLoadFailure(r)};this.headerView=new c({el:$("#header")});return this.headerView.on("update-swagger-ui",function(r){return q.updateSwaggerUi(r)})};n.prototype.updateSwaggerUi=function(p){this.options.discoveryUrl=p.discoveryUrl;this.options.apiKey=p.apiKey;return this.load()};n.prototype.load=function(){var p;if((p=this.mainView)!=null){p.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};n.prototype.render=function(){var p=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new i({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)};n.prototype.showMessage=function(p){if(p==null){p=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(p)};n.prototype.onLoadFailure=function(p){var q;if(p==null){p=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");q=$("#message-bar").html(p);if(this.options.onFailure!=null){this.options.onFailure(p)}return q};return n})(Backbone.Router);window.SwaggerUi=b;c=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.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"};n.prototype.initialize=function(){};n.prototype.showPetStore=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};n.prototype.showWordnikDev=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};n.prototype.showCustomOnKeyup=function(p){if(p.keyCode===13){return this.showCustom()}};n.prototype.showCustom=function(p){if(p!=null){p.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};n.prototype.update=function(q,r,p){if(p==null){p=false}$("#input_baseUrl").val(q);$("#input_apiKey").val(r);if(p){return this.trigger("update-swagger-ui",{discoveryUrl:q,apiKey:r})}};return n})(Backbone.View);i=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var s,r,p,q;$(this.el).html(Handlebars.templates.main(this.model));q=this.model.apisArray;for(r=0,p=q.length;r0){u[w.name]=w.value}}console.log(u);u.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();u.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();return this.model["do"](u,this.showCompleteStatus,this.showErrorStatus,this)}};n.prototype.success=function(p,q){return q.showCompleteStatus(p)};n.prototype.hideResponse=function(p){if(p!=null){p.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};n.prototype.showResponse=function(p){var q;q=JSON.stringify(p,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(q))};n.prototype.showErrorStatus=function(q,p){return p.showStatus(q)};n.prototype.showCompleteStatus=function(q,p){return p.showStatus(q)};n.prototype.formatXml=function(w){var s,v,q,x,C,y,r,p,A,B,u,t,z;p=/(>)(<)(\/*)/g;B=/[ ]*(.*)[ ]+\n/g;s=/(<.+>)(.+\n)/g;w=w.replace(p,"$1\n$2$3").replace(B,"$1\n").replace(s,"$1\n$2");r=0;v="";C=w.split("\n");q=0;x="other";A={"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};u=function(I){var E,D,G,K,H,F,J;F={single:Boolean(I.match(/<.+\/>/)),closing:Boolean(I.match(/<\/.+>/)),opening:Boolean(I.match(/<[^!?].*>/))};H=((function(){var L;L=[];for(G in F){J=F[G];if(J){L.push(G)}}return L})())[0];H=H===void 0?"other":H;E=x+"->"+H;x=H;K="";q+=A[E];K=((function(){var M,N,L;L=[];for(D=M=0,N=q;0<=N?MN;D=0<=N?++M:--M){L.push(" ")}return L})()).join("");if(E==="opening->closing"){return v=v.substr(0,v.length-1)+I+"\n"}else{return v+=K+I+"\n"}};for(t=0,z=C.length;t").text("no content");t=$('
').append(r)}else{if(v.indexOf("application/json")===0){r=$("").text(JSON.stringify(JSON.parse(q),null,2));t=$('
').append(r)}else{if(v.indexOf("application/xml")===0){r=$("").text(this.formatXml(q));t=$('
').append(r)}else{if(v.indexOf("text/html")===0){r=$("").html(q);t=$('
').append(r)}else{r=$("").text(q);t=$('
').append(r)}}}}p=t;$(".request_url").html("
"+s.request.url+"
");$(".response_code",$(this.el)).html("
"+s.status+"
");$(".response_body",$(this.el)).html(p);$(".response_headers",$(this.el)).html("
"+JSON.stringify(s.getHeaders())+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};n.prototype.toggleOperationContent=function(){var p;p=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(p.is(":visible")){return Docs.collapseOperation(p)}else{return Docs.expandOperation(p)}};return n})(Backbone.View);j=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));return this};n.prototype.template=function(){return Handlebars.templates.status_code};return n})(Backbone.View);f=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var u,p,r,t,q,v,s;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}s=this.template();$(this.el).html(s(this.model));q={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){v=new l({model:q,tagName:"div"});$(".model-signature",$(this.el)).append(v.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}p=false;if(this.model.isBody){p=true}u={isParam:p};u.consumes=this.model.consumes;if(p){r=new m({model:u});$(".parameter-content-type",$(this.el)).append(r.render().el)}else{t=new a({model:u});$(".response-content-type",$(this.el)).append(t.render().el)}return this};n.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 n})(Backbone.View);l=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};n.prototype.template=function(){return Handlebars.templates.signature};n.prototype.switchToDescription=function(p){if(p!=null){p.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};n.prototype.switchToSnippet=function(p){if(p!=null){p.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};n.prototype.snippetToTextArea=function(p){var q;if(this.isParam){if(p!=null){p.preventDefault()}q=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(q.val())===""){return q.val(this.model.sampleJSON)}}};return n})(Backbone.View);g=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.content_type};return o})(Backbone.View);a=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.response_content_type};return o})(Backbone.View);m=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};n.prototype.template=function(){return Handlebars.templates.parameter_content_type};return n})(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,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , api version: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n
\n
    \n
\n\n
\n
\n
\n

[ base url: ";j=e.basePath;c=j||p.basePath;if(typeof c===g){c=c.call(p,{hash:{}})}else{if(c===h){c=o.call(p,"basePath",{hash:{}})}}k+=l(c)+"\n ";j=e.apiVersion;c=j||p.apiVersion;r=e["if"];i=q.program(1,d,m);i.hash={};i.fn=i;i.inverse=q.noop;c=r.call(p,c,i);if(c||c===0){k+=c}k+="]

\n
\n
\n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,w){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(A,z){var x="",y;x+="\n

Implementation Notes

\n

";i=s.notes;y=i||A.notes;if(typeof y===e){y=y.call(A,{hash:{}})}else{if(y===c){y=r.call(A,"notes",{hash:{}})}}if(y||y===0){x+=y}x+="

\n ";return x}function n(y,x){return'\n

Response Class

\n

\n
\n
\n '}function l(y,x){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function k(y,x){return"\n
\n

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "}function f(y,x){return"\n "}function v(y,x){return"\n
\n \n \n \n
\n "}t+="\n \n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n \n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n \n ";return z}function k(C,B){var z="",A;z+="\n \n
\n
\n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n \n ";return z}function w(C,B){var z="",A;z+="\n \n ";return z}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n \n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n \n ";return y}function w(B,A){var y="",z;y+="\n \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+"\n\n \n\n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+="\n";j=t.paramType;k=j||v.paramType;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"paramType",{hash:{}})}}if(k||k===0){u+=k}u+='\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+"\n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n\n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+="\n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+='\n\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,t,r,k,u){r=r||g.helpers;var s="",i,f,h,p,o=this,e="function",q=r.helperMissing,c=void 0,d=this.escapeExpression;function n(y,x){var v="",w;v+="\n \n ";return v}function m(z,y){var v="",x,w;v+="\n ";h=r.defaultValue;x=h||z.defaultValue;w=r["if"];p=o.program(4,l,y);p.hash={};p.fn=p;p.inverse=o.program(6,j,y);x=w.call(z,x,p);if(x||x===0){v+=x}v+="\n ";return v}function l(y,x){var v="",w;v+="\n ";h=r.defaultValue;w=h||y.defaultValue;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"defaultValue",{hash:{}})}}v+=d(w)+"\n ";return v}function j(w,v){return"\n (empty)\n "}s+="";h=r.name;i=h||t.name;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"name",{hash:{}})}}s+=d(i)+"\n\n ";h=r.isBody;i=h||t.isBody;f=r["if"];p=o.program(1,n,u);p.hash={};p.fn=p;p.inverse=o.program(3,m,u);i=f.call(t,i,p);if(i||i===0){s+=i}s+="\n\n";h=r.description;i=h||t.description;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"description",{hash:{}})}}if(i||i===0){s+=i}s+="\n";h=r.paramType;i=h||t.paramType;if(typeof i===e){i=i.call(t,{hash:{}})}else{if(i===c){i=q.call(t,"paramType",{hash:{}})}}if(i||i===0){s+=i}s+='\n\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n \n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n \n ";return B}function k(E,D){var B="",C;B+="\n \n
\n
\n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n \n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n \n ";return B}function w(E,D){var B="",C;B+="\n \n ";return B}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+="\n\n";i=t.paramType;j=i||v.paramType;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"paramType",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.consumes;v=k||x.consumes;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.produces;v=k||x.produces;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='
\n\n
\n\n
\n
\n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n
\n\n
\n
';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'
\n \n
\n
\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+"\n";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+="\n\n";return i})})();(function(){var g,c,i,d,m,f,k,a,l,j,b,h={}.hasOwnProperty,e=function(q,o){for(var n in o){if(h.call(o,n)){q[n]=o[n]}}function p(){this.constructor=q}p.prototype=o.prototype;q.prototype=new p();q.__super__=o.prototype;return q};b=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.dom_id="swagger_ui";n.prototype.options=null;n.prototype.api=null;n.prototype.headerView=null;n.prototype.mainView=null;n.prototype.initialize=function(p){var q=this;if(p==null){p={}}if(p.dom_id!=null){this.dom_id=p.dom_id;delete p.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=p;this.options.success=function(){return q.render()};this.options.progress=function(r){return q.showMessage(r)};this.options.failure=function(r){return q.onLoadFailure(r)};this.headerView=new c({el:$("#header")});return this.headerView.on("update-swagger-ui",function(r){return q.updateSwaggerUi(r)})};n.prototype.updateSwaggerUi=function(p){this.options.discoveryUrl=p.discoveryUrl;return this.load()};n.prototype.load=function(){var p;if((p=this.mainView)!=null){p.clear()}this.headerView.update(this.options.discoveryUrl);return this.api=new SwaggerApi(this.options)};n.prototype.render=function(){var p=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new i({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)};n.prototype.showMessage=function(p){if(p==null){p=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(p)};n.prototype.onLoadFailure=function(p){var q;if(p==null){p=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");q=$("#message-bar").html(p);if(this.options.onFailure!=null){this.options.onFailure(p)}return q};return n})(Backbone.Router);window.SwaggerUi=b;c=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.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"};n.prototype.initialize=function(){};n.prototype.showPetStore=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json"})};n.prototype.showWordnikDev=function(p){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json"})};n.prototype.showCustomOnKeyup=function(p){if(p.keyCode===13){return this.showCustom()}};n.prototype.showCustom=function(p){if(p!=null){p.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};n.prototype.update=function(q,r,p){if(p==null){p=false}$("#input_baseUrl").val(q);$("#input_apiKey").val(r);if(p){return this.trigger("update-swagger-ui",{discoveryUrl:q,apiKey:r})}};return n})(Backbone.View);i=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var s,r,p,q;$(this.el).html(Handlebars.templates.main(this.model));q=this.model.apisArray;for(r=0,p=q.length;r0){q[s.name]=s.value}}console.log(q);p.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();p.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();return this.model["do"](q,p,this.showCompleteStatus,this.showErrorStatus,this)}};n.prototype.success=function(p,q){return q.showCompleteStatus(p)};n.prototype.hideResponse=function(p){if(p!=null){p.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};n.prototype.showResponse=function(p){var q;q=JSON.stringify(p,null,"\t").replace(/\n/g,"
");return $(".response_body",$(this.el)).html(escape(q))};n.prototype.showErrorStatus=function(q,p){return p.showStatus(q)};n.prototype.showCompleteStatus=function(q,p){return p.showStatus(q)};n.prototype.formatXml=function(w){var s,v,q,x,C,y,r,p,A,B,u,t,z;p=/(>)(<)(\/*)/g;B=/[ ]*(.*)[ ]+\n/g;s=/(<.+>)(.+\n)/g;w=w.replace(p,"$1\n$2$3").replace(B,"$1\n").replace(s,"$1\n$2");r=0;v="";C=w.split("\n");q=0;x="other";A={"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};u=function(I){var E,D,G,K,H,F,J;F={single:Boolean(I.match(/<.+\/>/)),closing:Boolean(I.match(/<\/.+>/)),opening:Boolean(I.match(/<[^!?].*>/))};H=((function(){var L;L=[];for(G in F){J=F[G];if(J){L.push(G)}}return L})())[0];H=H===void 0?"other":H;E=x+"->"+H;x=H;K="";q+=A[E];K=((function(){var M,N,L;L=[];for(D=M=0,N=q;0<=N?MN;D=0<=N?++M:--M){L.push(" ")}return L})()).join("");if(E==="opening->closing"){return v=v.substr(0,v.length-1)+I+"\n"}else{return v+=K+I+"\n"}};for(t=0,z=C.length;t").text("no content");t=$('
').append(r)}else{if(v.indexOf("application/json")===0){r=$("").text(JSON.stringify(JSON.parse(q),null,2));t=$('
').append(r)}else{if(v.indexOf("application/xml")===0){r=$("").text(this.formatXml(q));t=$('
').append(r)}else{if(v.indexOf("text/html")===0){r=$("").html(q);t=$('
').append(r)}else{r=$("").text(q);t=$('
').append(r)}}}}p=t;$(".request_url").html("
"+s.request.url+"
");$(".response_code",$(this.el)).html("
"+s.status+"
");$(".response_body",$(this.el)).html(p);$(".response_headers",$(this.el)).html("
"+JSON.stringify(s.getHeaders())+"
");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};n.prototype.toggleOperationContent=function(){var p;p=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.method+"_"+this.model.number+"_content");if(p.is(":visible")){return Docs.collapseOperation(p)}else{return Docs.expandOperation(p)}};return n})(Backbone.View);j=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));return this};n.prototype.template=function(){return Handlebars.templates.status_code};return n})(Backbone.View);f=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var u,p,r,t,q,v,s;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}s=this.template();$(this.el).html(s(this.model));q={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){v=new l({model:q,tagName:"div"});$(".model-signature",$(this.el)).append(v.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}p=false;if(this.model.isBody){p=true}u={isParam:p};u.consumes=this.model.consumes;if(p){r=new m({model:u});$(".parameter-content-type",$(this.el)).append(r.render().el)}else{t=new a({model:u});$(".response-content-type",$(this.el)).append(t.render().el)}return this};n.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 n})(Backbone.View);l=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};n.prototype.template=function(){return Handlebars.templates.signature};n.prototype.switchToDescription=function(p){if(p!=null){p.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};n.prototype.switchToSnippet=function(p){if(p!=null){p.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};n.prototype.snippetToTextArea=function(p){var q;if(this.isParam){if(p!=null){p.preventDefault()}q=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(q.val())===""){return q.val(this.model.sampleJSON)}}};return n})(Backbone.View);g=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.content_type};return o})(Backbone.View);a=(function(n){e(o,n);function o(){return o.__super__.constructor.apply(this,arguments)}o.prototype.initialize=function(){};o.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};o.prototype.template=function(){return Handlebars.templates.response_content_type};return o})(Backbone.View);m=(function(o){e(n,o);function n(){return n.__super__.constructor.apply(this,arguments)}n.prototype.initialize=function(){};n.prototype.render=function(){var p;p=this.template();$(this.el).html(p(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};n.prototype.template=function(){return Handlebars.templates.parameter_content_type};return n})(Backbone.View)}).call(this); \ No newline at end of file diff --git a/lib/swagger.js b/lib/swagger.js index 177a109d..ab46cc93 100644 --- a/lib/swagger.js +++ b/lib/swagger.js @@ -38,6 +38,7 @@ var obj, _this = this; this.progress('fetching resource list: ' + this.discoveryUrl); + console.log('getting ' + this.discoveryUrl); obj = { url: this.discoveryUrl, method: "get", @@ -79,7 +80,8 @@ } } }; - return new SwaggerHttp().execute(obj); + new SwaggerHttp().execute(obj); + return this; }; SwaggerApi.prototype.selfReflect = function() { @@ -519,6 +521,9 @@ this.resource[this.nickname] = function(args, callback, error) { return _this["do"](args, callback, error); }; + this.resource[this.nickname].help = function() { + return _this.help(); + }; } SwaggerOperation.prototype.isListType = function(dataType) { @@ -555,18 +560,25 @@ } }; - SwaggerOperation.prototype["do"] = function(args, callback, error) { - var key, param, params, possibleParams, requestContentType, responseContentType, value; + SwaggerOperation.prototype["do"] = function(args, opts, callback, error) { + var key, param, params, possibleParams, req, requestContentType, responseContentType, value; if (args == null) { args = {}; } + if (opts == null) { + opts = {}; + } requestContentType = null; responseContentType = null; if ((typeof args) === "function") { - error = callback; + error = opts; callback = args; args = {}; } + if ((typeof opts) === "function") { + error = callback; + callback = opts; + } if (error == null) { error = function(xhr, textStatus, error) { return console.log(xhr, textStatus, error); @@ -574,16 +586,17 @@ } if (callback == null) { callback = function(data) { - return console.log("default callback: " + data); + var content; + content = null; + if (data.content != null) { + content = data.content.data; + } else { + content = "no data"; + } + return console.log("default callback: " + content); }; } params = {}; - if (args.requestContentType) { - requestContentType = args.requestContentType; - } - if (args.responseContentType) { - responseContentType = args.responseContentType; - } if (args.headers != null) { params.headers = args.headers; delete args.headers; @@ -612,11 +625,12 @@ } } } - if (args.mock != null) { - params.mock = args["mock"]; + req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this); + if (opts.mock != null) { + return req; + } else { + return true; } - params["parent"] = args["parent"]; - return new SwaggerRequest(this.method, this.urlify(args), params, requestContentType, responseContentType, callback, error, this); }; SwaggerOperation.prototype.pathJson = function() { @@ -716,14 +730,13 @@ SwaggerRequest = (function() { - function SwaggerRequest(type, url, params, requestContentType, responseContentType, successCallback, errorCallback, operation, execution) { - var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, urlEncoded, value, values, + function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) { + var body, e, fields, headers, key, myHeaders, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values, _this = this; this.type = type; this.url = url; this.params = params; - this.requestContentType = requestContentType; - this.responseContentType = responseContentType; + this.opts = opts; this.successCallback = successCallback; this.errorCallback = errorCallback; this.operation = operation; @@ -750,8 +763,8 @@ parent = params["parent"]; requestContentType = "application/json"; if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) { - if (this.requestContentType) { - requestContentType = this.requestContentType; + if (this.opts.requestContentType) { + requestContentType = this.opts.requestContentType; } } else { if (((function() { @@ -777,14 +790,12 @@ if (this.requestContentType === null) { requestContentType = this.operation.consumes[0]; } - } else { - console.log("it's ok to send " + requestContentType); } } responseContentType = null; if (this.type === "POST" || this.type === "GET") { - if (this.responseContentType) { - responseContentType = this.responseContentType; + if (this.opts.responseContentType) { + responseContentType = this.opts.responseContentType; } else { responseContentType = "application/json"; } @@ -794,12 +805,9 @@ if (responseContentType && this.operation.produces) { if (this.operation.produces.indexOf(responseContentType) === -1) { console.log("server can't produce " + responseContentType); - } else { - console.log("get ready for " + responseContentType); } } if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) { - console.log("pulling fields"); fields = {}; possibleParams = (function() { var _i, _len, _ref, _results; @@ -813,7 +821,6 @@ } return _results; }).call(this); - console.log(possibleParams); values = {}; for (key in possibleParams) { value = possibleParams[key]; @@ -845,16 +852,16 @@ body: body, on: { error: function(response) { - return _this.errorCallback(response, _this.params["parent"]); + return _this.errorCallback(response, _this.opts.parent); }, redirect: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); }, 307: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); }, response: function(response) { - return _this.successCallback(response, _this.params["parent"]); + return _this.successCallback(response, _this.opts.parent); } } }; @@ -865,9 +872,10 @@ e = exports; } e.authorizations.apply(obj); - if (params.mock == null) { + if (opts.mock == null) { new SwaggerHttp().execute(obj); } else { + console.log(obj); return obj; } } @@ -894,33 +902,42 @@ SwaggerHttp = (function() { + SwaggerHttp.prototype.Shred = null; + SwaggerHttp.prototype.shred = null; - function SwaggerHttp() { - var Shred; - Shred = null; - if (typeof window !== 'undefined') { - Shred = require("./shred"); - } else { - Shred = require("shred"); - } - this.shred = new Shred(); - } + SwaggerHttp.prototype.content = null; - SwaggerHttp.prototype.execute = function(obj) { - var Content, identity, toString, + function SwaggerHttp() { + var identity, toString, _this = this; - Content = require("./shred/content"); + if (typeof window !== 'undefined') { + this.Shred = require("./shred"); + } else { + this.Shred = require("shred"); + } + this.shred = new this.Shred(); identity = function(x) { return x; }; toString = function(x) { return x.toString; }; - Content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { - parser: identity, - stringify: toString - }); + if (typeof window !== 'undefined') { + this.content = require("./shred/content"); + 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"], { + parser: identity, + stringify: toString + }); + } + } + + SwaggerHttp.prototype.execute = function(obj) { return this.shred.request(obj); }; @@ -997,8 +1014,6 @@ this.SwaggerModelProperty = SwaggerModelProperty; - this.SwaggerAuthorizations = new SwaggerAuthorizations(); - this.ApiKeyAuthorization = ApiKeyAuthorization; this.authorizations = new SwaggerAuthorizations(); diff --git a/src/main/coffeescript/SwaggerUi.coffee b/src/main/coffeescript/SwaggerUi.coffee index 10a0a1a3..c27ff269 100644 --- a/src/main/coffeescript/SwaggerUi.coffee +++ b/src/main/coffeescript/SwaggerUi.coffee @@ -35,14 +35,13 @@ class SwaggerUi extends Backbone.Router # Event handler for when url/key is received from user updateSwaggerUi: (data) -> @options.discoveryUrl = data.discoveryUrl - @options.apiKey = data.apiKey @load() # Create an api and render load: -> # Initialize the API object @mainView?.clear() - @headerView.update(@options.discoveryUrl, @options.apiKey) + @headerView.update(@options.discoveryUrl) @api = new SwaggerApi(@options) # This is bound to success handler for SwaggerApi diff --git a/src/main/coffeescript/view/HeaderView.coffee b/src/main/coffeescript/view/HeaderView.coffee index 527fa71e..96d17cf2 100644 --- a/src/main/coffeescript/view/HeaderView.coffee +++ b/src/main/coffeescript/view/HeaderView.coffee @@ -9,17 +9,16 @@ class HeaderView extends Backbone.View initialize: -> - showPetStore: (e) -> @trigger( 'update-swagger-ui' - {discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json", apiKey:"special-key"} + {discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json"} ) showWordnikDev: (e) -> @trigger( 'update-swagger-ui' - {discoveryUrl:"http://api.wordnik.com/v4/resources.json", apiKey:""} + {discoveryUrl:"http://api.wordnik.com/v4/resources.json"} ) showCustomOnKeyup: (e) -> diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee index a0d4e19b..d8f141e3 100644 --- a/src/main/coffeescript/view/OperationView.coffee +++ b/src/main/coffeescript/view/OperationView.coffee @@ -68,17 +68,18 @@ class OperationView extends Backbone.View # if error free submit it if error_free - map = {parent: @} + map = {} + opts = {parent: @} for o in form.serializeArray() if(o.value? && jQuery.trim(o.value).length > 0) map[o.name] = o.value console.log map - map["responseContentType"] = $("div select[name=responseContentType]", $(@el)).val() - map["requestContentType"] = $("div select[name=parameterContentType]", $(@el)).val() + opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val() + opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val() - @model.do(map, @showCompleteStatus, @showErrorStatus, @) + @model.do(map, opts, @showCompleteStatus, @showErrorStatus, @) success: (response, parent) -> parent.showCompleteStatus response diff --git a/src/main/html/index.html b/src/main/html/index.html index 5f9d8523..b09bc7d3 100644 --- a/src/main/html/index.html +++ b/src/main/html/index.html @@ -45,6 +45,7 @@ var key = $('#input_apiKey')[0].value; console.log("key: " + key); if(key && key.trim() != "") { + console.log("added key " + key); window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query")); } }) diff --git a/src/main/template/resource.handlebars b/src/main/template/resource.handlebars index 2b5b0b29..554b4a03 100644 --- a/src/main/template/resource.handlebars +++ b/src/main/template/resource.handlebars @@ -1,6 +1,6 @@