grape-swagger-rails 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +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 <option value="';u=w;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=o.call(w,"this",{hash:{}})}}if(u||u===0){t+=u}t+='">';u=w;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=o.call(w,"this",{hash:{}})}}if(u||u===0){t+=u}t+="</option>\n ";return t}function r(u,t){return'\n <option value="application/json">application/json</option>\n'}l+='<label for="contentType"></label>\n<select name="contentType">\n';k=f.produces;c=k||p.produces;s=f["if"];j=q.program(1,e,m);j.hash={};j.fn=j;j.inverse=q.program(4,r,m);c=s.call(p,c,j);if(c||c===0){l+=c}l+="\n</select>\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 , <span style="font-variant: small-caps">api version</span>: ';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<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";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+="]</h4>\n </div>\n</div>\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 <h4>Implementation Notes</h4>\n <p>";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+="</p>\n ";return x}function n(y,x){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="content-type" />\n '}function l(y,x){return'\n <h4>Parameters</h4>\n <table class=\'fullwidth\'>\n <thead>\n <tr>\n <th style="width: 100px; max-width: 100px" >Parameter</th>\n <th style="width: 310px; max-width: 310px">Value</th>\n <th style="width: 200px; max-width: 200px">Description</th>\n <th style="width: 320px; max-width: 330px">Data Type</th>\n </tr>\n </thead>\n <tbody class="operation-params">\n\n </tbody>\n </table>\n '}function k(y,x){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function f(y,x){return"\n "}function v(y,x){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n "}t+="\n <ul class='operations' >\n <li class='";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+" operation' id='";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"_";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.path;j=i||u.path;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"path",{hash:{}})}}t+=d(j)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"/";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+'\' class="toggleOperation">';i=s.summary;j=i||u.summary;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"summary",{hash:{}})}}if(j||j===0){t+=j}t+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";i=s.resourceName;j=i||u.resourceName;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"resourceName",{hash:{}})}}t+=d(j)+"_";i=s.nickname;j=i||u.nickname;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"nickname",{hash:{}})}}t+=d(j)+"_";i=s.httpMethod;j=i||u.httpMethod;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"httpMethod",{hash:{}})}}t+=d(j)+"_";i=s.number;j=i||u.number;if(typeof j===e){j=j.call(u,{hash:{}})}else{if(j===c){j=r.call(u,"number",{hash:{}})}}t+=d(j)+"_content' style='display:none'>\n ";i=s.notes;j=i||u.notes;g=s["if"];q=p.program(1,o,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.responseClass;j=i||u.responseClass;g=s["if"];q=p.program(3,n,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";i=s.parameters;j=i||u.parameters;g=s["if"];q=p.program(5,l,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.errorResponses;j=i||u.errorResponses;g=s["if"];q=p.program(7,k,w);q.hash={};q.fn=q;q.inverse=p.noop;j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n ";i=s.isReadOnly;j=i||u.isReadOnly;g=s["if"];q=p.program(9,f,w);q.hash={};q.fn=q;q.inverse=p.program(11,v,w);j=g.call(u,j,q);if(j||j===0){t+=j}t+="\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";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 <input type="file" name=\'';i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"'/>\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 <textarea class='body-textarea' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"'>";i=t.defaultValue;A=i||C.defaultValue;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"defaultValue",{hash:{}})}}z+=d(A)+"</textarea>\n ";return z}function k(C,B){var z="",A;z+="\n <textarea class='body-textarea' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+'\'></textarea>\n <br />\n <div class="content-type" />\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 <input class='parameter' minlength='0' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"' placeholder='' type='text' value='";i=t.defaultValue;A=i||C.defaultValue;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"defaultValue",{hash:{}})}}z+=d(A)+"'/>\n ";return z}function w(C,B){var z="",A;z+="\n <input class='parameter' minlength='0' name='";i=t.name;A=i||C.name;if(typeof A===e){A=A.call(C,{hash:{}})}else{if(A===c){A=s.call(C,"name",{hash:{}})}}z+=d(A)+"' placeholder='' type='text' value=''/>\n ";return z}u+="<td class='code'>";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)+"</td>\n<td>\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</td>\n<td>";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+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\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 <option selected=\"\" value=''></option>\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 <option value='";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"'>";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+" (default)</option>\n ";return y}function w(B,A){var y="",z;y+="\n <option value='";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"'>";j=t.value;z=j||B.value;if(typeof z===e){z=z.call(B,{hash:{}})}else{if(z===c){z=s.call(B,"value",{hash:{}})}}y+=d(z)+"</option>\n ";return y}u+="<td class='code'>";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)+"</td>\n<td>\n <select class='parameter' name='";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 ";j=t.required;k=j||v.required;g=t["if"];r=q.program(1,p,x);r.hash={};r.fn=r;r.inverse=q.program(3,o,x);k=g.call(v,k,r);if(k||k===0){u+=k}u+="\n ";j=t.allowableValues;k=j||v.allowableValues;k=(k===null||k===undefined||k===false?k:k.descriptiveValues);g=t.each;r=q.program(8,i,x);r.hash={};r.fn=r;r.inverse=q.noop;k=g.call(v,k,r);if(k||k===0){u+=k}u+="\n </select>\n</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <textarea class='body-textarea' readonly='readonly' name='";h=r.name;w=h||y.name;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"name",{hash:{}})}}v+=d(w)+"'>";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)+"</textarea>\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+="<td class='code'>";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)+"</td>\n<td>\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</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";h=r.name;w=h||y.name;if(typeof w===e){w=w.call(y,{hash:{}})}else{if(w===c){w=q.call(y,"name",{hash:{}})}}v+=d(w)+"'>";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)+"</textarea>\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+="<td class='code required'>";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)+"</td>\n<td>\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</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <input type="file" name=\'';i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'/>\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 <textarea class='body-textarea' placeholder='(required)' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'>";i=t.defaultValue;C=i||E.defaultValue;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"defaultValue",{hash:{}})}}B+=d(C)+"</textarea>\n ";return B}function k(E,D){var B="",C;B+="\n <textarea class='body-textarea' placeholder='(required)' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+'\'></textarea>\n <br />\n <div class="content-type" />\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 <input class='parameter' class='required' type='file' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"'/>\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 <input class='parameter required' minlength='1' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"' placeholder='(required)' type='text' value='";i=t.defaultValue;C=i||E.defaultValue;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"defaultValue",{hash:{}})}}B+=d(C)+"'/>\n ";return B}function w(E,D){var B="",C;B+="\n <input class='parameter required' minlength='1' name='";i=t.name;C=i||E.name;if(typeof C===e){C=C.call(E,{hash:{}})}else{if(C===c){C=s.call(E,"name",{hash:{}})}}B+=d(C)+"' placeholder='(required)' type='text' value=''/>\n ";return B}u+="<td class='code required'>";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)+"</td>\n<td>\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</td>\n<td>\n <strong>";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+='</strong>\n</td>\n<td><span class="model-signature"></span></td>\n';return u})})();(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+="<div class='heading'>\n <h2>\n <a href='#!/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"' onclick=\"Docs.toggleEndpointListForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"');\">/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"</a>\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"' id='endpointListTogger_";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'\n onclick=\"Docs.toggleEndpointListForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";h=d.url;c=h||n.url;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"url",{hash:{}})}}i+=j(c)+"'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";h=d.name;c=h||n.name;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"name",{hash:{}})}}i+=j(c)+"_endpoint_list' style='display:none'>\n\n</ul>\n";return i})})();(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+='<div>\n<ul class="signature-nav">\n <li><a class="description-link" href="#">Model</a></li>\n <li><a class="snippet-link" href="#">Model Schema</a></li>\n</ul>\n<div>\n\n<div class="signature-container">\n <div class="description">\n ';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 </div>\n\n <div class="snippet">\n <pre><code>';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)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\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+="<td width='15%' class='code'>";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)+"</td>\n<td>";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+="</td>\n\n";return i})})();(function(){var f,b,h,c,e,j,k,i,a,g={}.hasOwnProperty,d=function(o,m){for(var l in m){if(g.call(m,l)){o[l]=m[l]}}function n(){this.constructor=o}n.prototype=m.prototype;o.prototype=new n();o.__super__=m.prototype;return o};a=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.dom_id="swagger_ui";l.prototype.options=null;l.prototype.api=null;l.prototype.headerView=null;l.prototype.mainView=null;l.prototype.initialize=function(n){var o=this;if(n==null){n={}}if(n.dom_id!=null){this.dom_id=n.dom_id;delete n.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('<div id="'+this.dom_id+'"></div>')}this.options=n;this.options.success=function(){return o.render()};this.options.progress=function(p){return o.showMessage(p)};this.options.failure=function(p){return o.onLoadFailure(p)};this.headerView=new b({el:$("#header")});return this.headerView.on("update-swagger-ui",function(p){return o.updateSwaggerUi(p)})};l.prototype.updateSwaggerUi=function(n){this.options.discoveryUrl=n.discoveryUrl;this.options.apiKey=n.apiKey;return this.load()};l.prototype.load=function(){var n;if((n=this.mainView)!=null){n.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};l.prototype.render=function(){var n=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({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)};l.prototype.showMessage=function(n){if(n==null){n=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(n)};l.prototype.onLoadFailure=function(n){var o;if(n==null){n=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");o=$("#message-bar").html(n);if(this.options.onFailure!=null){this.options.onFailure(n)}return o};return l})(Backbone.Router);window.SwaggerUi=a;b=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.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"};l.prototype.initialize=function(){};l.prototype.showPetStore=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};l.prototype.showWordnikDev=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};l.prototype.showCustomOnKeyup=function(n){if(n.keyCode===13){return this.showCustom()}};l.prototype.showCustom=function(n){if(n!=null){n.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};l.prototype.update=function(o,p,n){if(n==null){n=false}$("#input_baseUrl").val(o);$("#input_apiKey").val(p);if(n){return this.trigger("update-swagger-ui",{discoveryUrl:o,apiKey:p})}};return l})(Backbone.View);h=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var q,p,n,o;$(this.el).html(Handlebars.templates.main(this.model));o=this.model.apisArray;for(p=0,n=o.length;p<n;p++){q=o[p];this.addResource(q)}return this};m.prototype.addResource=function(o){var n;n=new j({model:o,tagName:"li",id:"resource_"+o.name,className:"resource"});return $("#resources").append(n.render().el)};m.prototype.clear=function(){return $(this.el).html("")};return m})(Backbone.View);j=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var o,q,n,p;$(this.el).html(Handlebars.templates.resource(this.model));this.number=0;p=this.model.operationsArray;for(q=0,n=p.length;q<n;q++){o=p[q];this.addOperation(o)}return this};l.prototype.addOperation=function(n){var o;n.number=this.number;o=new c({model:n,tagName:"li",className:"endpoint"});$(".endpoints",$(this.el)).append(o.render().el);return this.number++};return l})(Backbone.View);c=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent"};l.prototype.initialize=function(){};l.prototype.render=function(){var n,x,y,p,u,z,v,s,r,w,o,t,q;y=jQuery.inArray(this.model.httpMethod,this.model.supportedSubmitMethods())>=0;if(!y){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){z={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};u=new k({model:z,tagName:"div"});$(".model-signature",$(this.el)).append(u.render().el)}else{$(".model-signature",$(this.el)).html(this.model.responseClass)}n={isParam:false};if(this.model.supportedContentTypes){n.produces=this.model.supportedContentTypes}if(this.model.produces){n.produces=this.model.produces}x=new f({model:n});$(".content-type",$(this.el)).append(x.render().el);t=this.model.parameters;for(s=0,w=t.length;s<w;s++){p=t[s];this.addParameter(p)}q=this.model.errorResponses;for(r=0,o=q.length;r<o;r++){v=q[r];this.addStatusCode(v)}return this};l.prototype.addParameter=function(o){var n;n=new e({model:o,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(n.render().el)};l.prototype.addStatusCode=function(o){var n;n=new i({model:o,tagName:"tr"});return $(".operation-status",$(this.el)).append(n.render().el)};l.prototype.submitOperation=function(K){var F,L,E,v,q,A,P,J,Q,H,D,B,G,s,x,u,r,p,O,S,R,N,M,n,C,z,y,w,t,I=this;if(K!=null){K.preventDefault()}v=$(".sandbox",$(this.el));E=true;v.find("input.required").each(function(){var o=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(o).focus()}});return E=false}});if(E){Q={};C=v.serializeArray();for(x=0,O=C.length;x<O;x++){H=C[x];if((H.value!=null)&&jQuery.trim(H.value).length>0){Q[H.name]=H.value}}P=v.children().find('input[type~="file"]').size()!==0;J=false;L="application/json";if(this.model.consumes&&this.model.consumes.length>0){L=this.model.consumes[0]}else{z=this.model.parameters;for(u=0,S=z.length;u<S;u++){H=z[u];if(H.paramType==="form"){J=true;L=false}}if(P){L=false}else{if(this.model.httpMethod.toLowerCase()==="post"&&J===false){L="application/json"}}}if(P){F=new FormData();y=this.model.parameters;for(r=0,R=y.length;r<R;r++){B=y[r];if((B.paramType==="body"||"form")&&B.name!=="file"&&(Q[B.name]!=null)){F.append(B.name,Q[B.name])}}$.each(v.children().find('input[type~="file"]'),function(o,T){return F.append($(T).attr("name"),T.files[0])});console.log(F)}else{if(J){F=new FormData();w=this.model.parameters;for(p=0,N=w.length;p<N;p++){B=w[p];if(Q[B.name]!=null){F.append(B.name,Q[B.name])}}}else{F=null;t=this.model.parameters;for(n=0,M=t.length;n<M;n++){B=t[n];if(B.paramType==="body"){F=Q[B.name]}}}}log("bodyParam = "+F);q=null;A=this.model.supportHeaderParams()?(q=this.model.getHeaderParams(Q),this.model.urlify(Q,false)):this.model.urlify(Q,true);log("submitting "+A);$(".request_url",$(this.el)).html("<pre>"+A+"</pre>");$(".response_throbber",$(this.el)).show();D={type:this.model.httpMethod,url:A,headers:q,data:F,contentType:L,dataType:"json",processData:false,error:function(T,U,o){return I.showErrorStatus(T,U,o)},success:function(o){return I.showResponse(o)},complete:function(o){return I.showCompleteStatus(o)}};G=$("td select[name=contentType]",$(this.el)).val();if(G){D.contentType=G}log("content type = "+D.contentType);if(!D.data||(D.type==="GET"||D.type==="DELETE")){D.contentType=false}log("content type is now = "+D.contentType);s=$(".content > .content-type > div > select[name=contentType]",$(this.el)).val();if(s){D.headers=D.headers!=null?D.headers:{};D.headers.accept=s}jQuery.ajax(D);return false}};l.prototype.hideResponse=function(n){if(n!=null){n.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};l.prototype.showResponse=function(n){var o;o=JSON.stringify(n,null,"\t").replace(/\n/g,"<br>");return $(".response_body",$(this.el)).html(escape(o))};l.prototype.showErrorStatus=function(n){return this.showStatus(n)};l.prototype.showCompleteStatus=function(n){return this.showStatus(n)};l.prototype.formatXml=function(u){var q,t,o,v,A,w,p,n,y,z,s,r,x;n=/(>)(<)(\/*)/g;z=/[ ]*(.*)[ ]+\n/g;q=/(<.+>)(.+\n)/g;u=u.replace(n,"$1\n$2$3").replace(z,"$1\n").replace(q,"$1\n$2");p=0;t="";A=u.split("\n");o=0;v="other";y={"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};s=function(G){var C,B,E,I,F,D,H;D={single:Boolean(G.match(/<.+\/>/)),closing:Boolean(G.match(/<\/.+>/)),opening:Boolean(G.match(/<[^!?].*>/))};F=((function(){var J;J=[];for(E in D){H=D[E];if(H){J.push(E)}}return J})())[0];F=F===void 0?"other":F;C=v+"->"+F;v=F;I="";o+=y[C];I=((function(){var K,L,J;J=[];for(B=K=0,L=o;0<=L?K<L:K>L;B=0<=L?++K:--K){J.push(" ")}return J})()).join("");if(C==="opening->closing"){return t=t.substr(0,t.length-1)+G+"\n"}else{return t+=I+G+"\n"}};for(r=0,x=A.length;r<x;r++){w=A[r];s(w)}return t};l.prototype.showStatus=function(q){var p,r,o;try{p=$("<code />").text(JSON.stringify(JSON.parse(q.responseText),null,2));r=$('<pre class="json" />').append(p)}catch(n){p=$("<code />").text(this.formatXml(q.responseText));r=$('<pre class="xml" />').append(p)}o=r;$(".response_code",$(this.el)).html("<pre>"+q.status+"</pre>");$(".response_body",$(this.el)).html(o);$(".response_headers",$(this.el)).html("<pre>"+q.getAllResponseHeaders()+"</pre>");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};l.prototype.toggleOperationContent=function(){var n;n=$("#"+Docs.escapeResourceName(this.model.resourceName)+"_"+this.model.nickname+"_"+this.model.httpMethod+"_"+this.model.number+"_content");if(n.is(":visible")){return Docs.collapseOperation(n)}else{return Docs.expandOperation(n)}};return l})(Backbone.View);i=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));return this};l.prototype.template=function(){return Handlebars.templates.status_code};return l})(Backbone.View);e=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var q,o,n,r,p;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}p=this.template();$(this.el).html(p(this.model));n={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){r=new k({model:n,tagName:"div"});$(".model-signature",$(this.el)).append(r.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}q={isParam:false};if(this.model.supportedContentTypes){q.produces=this.model.supportedContentTypes}if(this.model.produces){q.produces=this.model.produces}o=new f({model:q});$(".content-type",$(this.el)).append(o.render().el);return this};l.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 l})(Backbone.View);k=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};l.prototype.template=function(){return Handlebars.templates.signature};l.prototype.switchToDescription=function(n){if(n!=null){n.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};l.prototype.switchToSnippet=function(n){if(n!=null){n.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};l.prototype.snippetToTextArea=function(n){var o;if(this.isParam){if(n!=null){n.preventDefault()}o=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(o.val())===""){return o.val(this.model.sampleJSON)}}};return l})(Backbone.View);f=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.isParam=this.model.isParam;if(this.isParam){$("label[for=contentType]",$(this.el)).text("Parameter content type:")}else{$("label[for=contentType]",$(this.el)).text("Response Content Type")}return this};m.prototype.template=function(){return Handlebars.templates.content_type};return m})(Backbone.View)}).call(this);
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 <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="contentType"></label>\n<select name="contentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\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 <div class="info_title">'+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'</div>\n <div class="info_description">';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+="</div>\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+='<div class="info_tos"><a href="'+j(((s=((s=u.info),s==null||s===false?s:s.termsOfServiceUrl)),typeof s===h?s.apply(u):s))+'">Terms of service</a></div>';return r}function q(u,t){var r="",s;r+="<div class='info_contact'><a href=\"mailto:"+j(((s=((s=u.info),s==null||s===false?s:s.contact)),typeof s===h?s.apply(u):s))+'">Contact the developer</a></div>';return r}function o(u,t){var r="",s;r+="<div class='info_license'><a href='"+j(((s=((s=u.info),s==null||s===false?s:s.licenseUrl)),typeof s===h?s.apply(u):s))+"'>"+j(((s=((s=u.info),s==null||s===false?s:s.license)),typeof s===h?s.apply(u):s))+"</a></div>";return r}function n(u,t){var r="",s;r+='\n , <span style="font-variant: small-caps">api version</span>: ';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+="<div class='info' id='api_info'>\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</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";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+="]</h4>\n </div>\n</div>\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 <h4>Implementation Notes</h4>\n <p>";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+="</p>\n ";return s}function c(t,s){return'\n <h4>Response Class</h4>\n <p><span class="model-signature" /></p>\n <br/>\n <div class="response-content-type" />\n '}function q(t,s){return'\n <h4>Parameters</h4>\n <table class=\'fullwidth\'>\n <thead>\n <tr>\n <th style="width: 100px; max-width: 100px">Parameter</th>\n <th style="width: 310px; max-width: 310px">Value</th>\n <th style="width: 200px; max-width: 200px">Description</th>\n <th style="width: 100px; max-width: 100px">Parameter Type</th>\n <th style="width: 220px; max-width: 230px">Data Type</th>\n </tr>\n </thead>\n <tbody class="operation-params">\n\n </tbody>\n </table>\n '}function p(t,s){return"\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Error Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n "}function o(t,s){return"\n "}function e(t,s){return"\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n "}j+="\n <ul class='operations' >\n <li class='";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+" operation' id='";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+"'>\n <div class='heading'>\n <h3>\n <span class='http_method'>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"</a>\n </span>\n <span class='path'>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.path){d=d.call(n,{hash:{},data:l})}else{d=n.path;d=typeof d===i?d.apply(n):d}j+=k(d)+"</a>\n </span>\n </h3>\n <ul class='options'>\n <li>\n <a href='#!/";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"/";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+'\' class="toggleOperation">';if(d=g.summary){d=d.call(n,{hash:{},data:l})}else{d=n.summary;d=typeof d===i?d.apply(n):d}if(d||d===0){j+=d}j+="</a>\n </li>\n </ul>\n </div>\n <div class='content' id='";if(d=g.resourceName){d=d.call(n,{hash:{},data:l})}else{d=n.resourceName;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.nickname){d=d.call(n,{hash:{},data:l})}else{d=n.nickname;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.method){d=d.call(n,{hash:{},data:l})}else{d=n.method;d=typeof d===i?d.apply(n):d}j+=k(d)+"_";if(d=g.number){d=d.call(n,{hash:{},data:l})}else{d=n.number;d=typeof d===i?d.apply(n):d}j+=k(d)+"_content' style='display:none'>\n ";d=g["if"].call(n,n.notes,{hash:{},inverse:r.noop,fn:r.program(1,f,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.type,{hash:{},inverse:r.noop,fn:r.program(3,c,l),data:l});if(d||d===0){j+=d}j+="\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";d=g["if"].call(n,n.parameters,{hash:{},inverse:r.noop,fn:r.program(5,q,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.responseMessages,{hash:{},inverse:r.noop,fn:r.program(7,p,l),data:l});if(d||d===0){j+=d}j+="\n ";d=g["if"].call(n,n.isReadOnly,{hash:{},inverse:r.program(11,e,l),fn:r.program(9,o,l),data:l});if(d||d===0){j+=d}j+="\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";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 <input type="file" name=\'';if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+'\'/>\n <div class="parameter-content-type" />\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 <textarea class='body-textarea' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"'>";if(v=o.defaultValue){v=v.call(x,{hash:{},data:w})}else{v=x.defaultValue;v=typeof v===d?v.apply(x):v}u+=c(v)+"</textarea>\n ";return u}function h(x,w){var u="",v;u+="\n <textarea class='body-textarea' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\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 <input class='parameter' minlength='0' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"' placeholder='' type='text' value='";if(v=o.defaultValue){v=v.call(x,{hash:{},data:w})}else{v=x.defaultValue;v=typeof v===d?v.apply(x):v}u+=c(v)+"'/>\n ";return u}function r(x,w){var u="",v;u+="\n <input class='parameter' minlength='0' name='";if(v=o.name){v=v.call(x,{hash:{},data:w})}else{v=x.name;v=typeof v===d?v.apply(x):v}u+=c(v)+"' placeholder='' type='text' value=''/>\n ";return u}p+="<td class='code'>";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)+"</td>\n<td>\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</td>\n<td>";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+="</td>\n<td>";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+='</td>\n<td>\n <span class="model-signature"></span>\n</td>\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 <option selected=\"\" value=''></option>\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 <option selected="" value=\'';if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"'>";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+" (default)</option>\n ";return x}function s(A,z){var x="",y;x+="\n <option value='";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"'>";if(y=p.value){y=y.call(A,{hash:{},data:z})}else{y=A.value;y=typeof y===d?y.apply(A):y}x+=c(y)+"</option>\n ";return x}q+="<td class='code'>";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)+"</td>\n<td>\n <select ";i=p["if"].call(r,r.allowMultiple,{hash:{},inverse:o.noop,fn:o.program(1,n,w),data:w});if(i||i===0){q+=i}q+=" class='parameter' name='";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 ";i=p["if"].call(r,r.required,{hash:{},inverse:o.program(5,k,w),fn:o.program(3,m,w),data:w});if(i||i===0){q+=i}q+="\n ";e=p.each.call(r,((i=r.allowableValues),i==null||i===false?i:i.descriptiveValues),{hash:{},inverse:o.noop,fn:o.program(13,u,w),data:w});if(e||e===0){q+=e}q+="\n </select>\n</td>\n<td>";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+="</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>';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 <textarea class='body-textarea' readonly='readonly' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";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)+"</textarea>\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+="<td class='code'>";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)+"</td>\n<td>\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</td>\n<td>";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+="</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='";if(r=f.name){r=r.call(t,{hash:{},data:s})}else{r=t.name;r=typeof r===h?r.apply(t):r}q+=j(r)+"'>";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)+"</textarea>\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+="<td class='code required'>";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)+"</td>\n<td>\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</td>\n<td>";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+="</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <input type="file" name=\'';if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\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 <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'>";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"</textarea>\n ";return w}function h(z,y){var w="",x;w+="\n <textarea class='body-textarea' placeholder='(required)' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+'\'></textarea>\n <br />\n <div class="parameter-content-type" />\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 <input class='parameter' class='required' type='file' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\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 <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value='";if(x=o.defaultValue){x=x.call(z,{hash:{},data:y})}else{x=z.defaultValue;x=typeof x===d?x.apply(z):x}w+=c(x)+"'/>\n ";return w}function r(z,y){var w="",x;w+="\n <input class='parameter required' minlength='1' name='";if(x=o.name){x=x.call(z,{hash:{},data:y})}else{x=z.name;x=typeof x===d?x.apply(z):x}w+=c(x)+"' placeholder='(required)' type='text' value=''/>\n ";return w}p+="<td class='code required'>";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)+"</td>\n<td>\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</td>\n<td>\n <strong>";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+="</strong>\n</td>\n<td>";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+='</td>\n<td><span class="model-signature"></span></td>\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 <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="parameterContentType"></label>\n<select name="parameterContentType">\n';c=f["if"].call(l,l.consumes,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\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+="<div class='heading'>\n <h2>\n <a href='#!/";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)+"' onclick=\"Docs.toggleEndpointListForResource('";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)+"');\">";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)+"</a> ";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 </h2>\n <ul class='options'>\n <li>\n <a href='#!/";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)+"' id='endpointListTogger_";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)+"'\n onclick=\"Docs.toggleEndpointListForResource('";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)+"');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";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)+"'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";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)+"'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";if(c=e.url){c=c.call(l,{hash:{},data:j})}else{c=l.url;c=typeof c===g?c.apply(l):c}h+=i(c)+"'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";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)+"_endpoint_list' style='display:none'>\n\n</ul>\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 <option value="';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+='">';p=(typeof r===h?r.apply(r):r);if(p||p===0){o+=p}o+="</option>\n ";return o}function n(p,o){return'\n <option value="application/json">application/json</option>\n'}i+='<label for="responseContentType"></label>\n<select name="responseContentType">\n';c=f["if"].call(l,l.produces,{hash:{},inverse:m.program(4,n,j),fn:m.program(1,e,j),data:j});if(c||c===0){i+=c}i+="\n</select>\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+='<div>\n<ul class="signature-nav">\n <li><a class="description-link" href="#">Model</a></li>\n <li><a class="snippet-link" href="#">Model Schema</a></li>\n</ul>\n<div>\n\n<div class="signature-container">\n <div class="description">\n ';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 </div>\n\n <div class="snippet">\n <pre><code>';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)+'</code></pre>\n <small class="notice"></small>\n </div>\n</div>\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+="<td width='15%' class='code'>";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)+"</td>\n<td>";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+="</td>\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('<div id="'+this.dom_id+'"></div>')}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;B<A;B++){C=D[B];this.addResource(C)}return this};z.prototype.addResource=function(B){var A;A=new n({model:B,tagName:"li",id:"resource_"+B.name,className:"resource"});return $("#resources").append(A.render().el)};z.prototype.clear=function(){return $(this.el).html("")};return z})(Backbone.View);n=(function(z){v(y,z);function y(){f=y.__super__.constructor.apply(this,arguments);return f}y.prototype.initialize=function(){};y.prototype.render=function(){var B,C,A,D;console.log(this.model.description);$(this.el).html(Handlebars.templates.resource(this.model));this.number=0;D=this.model.operationsArray;for(C=0,A=D.length;C<A;C++){B=D[C];this.addOperation(B)}return this};y.prototype.addOperation=function(A){var B;A.number=this.number;B=new o({model:A,tagName:"li",className:"endpoint"});$(".endpoints",$(this.el)).append(B.render().el);return this.number++};return y})(Backbone.View);o=(function(z){v(y,z);function y(){e=y.__super__.constructor.apply(this,arguments);return e}y.prototype.invocationUrl=null;y.prototype.events={"submit .sandbox":"submitOperation","click .submit":"submitOperation","click .response_hider":"hideResponse","click .toggleOperation":"toggleOperationContent"};y.prototype.initialize=function(){};y.prototype.render=function(){var A,P,G,M,K,Q,L,N,J,I,H,O,E,C,F,D,B;P=true;if(!P){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){Q={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};K=new i({model:Q,tagName:"div"});$(".model-signature",$(this.el)).append(K.render().el)}else{$(".model-signature",$(this.el)).html(this.model.type)}A={isParam:false};A.consumes=this.model.consumes;A.produces=this.model.produces;F=this.model.parameters;for(J=0,O=F.length;J<O;J++){G=F[J];N=G.type||G.dataType;if(N.toLowerCase()==="file"){if(!A.consumes){console.log("set content type ");A.consumes="multipart/form-data"}}}M=new m({model:A});$(".response-content-type",$(this.el)).append(M.render().el);D=this.model.parameters;for(I=0,E=D.length;I<E;I++){G=D[I];this.addParameter(G,A.consumes)}B=this.model.responseMessages;for(H=0,C=B.length;H<C;H++){L=B[H];this.addStatusCode(L)}return this};y.prototype.addParameter=function(C,A){var B;C.consumes=A;B=new k({model:C,tagName:"tr",readOnly:this.model.isReadOnly});return $(".operation-params",$(this.el)).append(B.render().el)};y.prototype.addStatusCode=function(B){var A;A=new p({model:B,tagName:"tr"});return $(".operation-status",$(this.el)).append(A.render().el)};y.prototype.submitOperation=function(O){var Q,G,N,D,I,A,J,M,L,K,P,F,C,H,E,B;if(O!=null){O.preventDefault()}G=$(".sandbox",$(this.el));Q=true;G.find("input.required").each(function(){var R=this;$(this).removeClass("error");if(jQuery.trim($(this).val())===""){$(this).addClass("error");$(this).wiggle({callback:function(){return $(R).focus()}});return Q=false}});if(Q){D={};A={parent:this};N=false;H=G.find("input");for(M=0,P=H.length;M<P;M++){I=H[M];if((I.value!=null)&&jQuery.trim(I.value).length>0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L<F;L++){I=E[L];if((I.value!=null)&&jQuery.trim(I.value).length>0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K<C;K++){I=B[K];J=this.getSelectedValue(I);if((J!=null)&&jQuery.trim(J).length>0){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(C,F){var Q,P,H,M,I,L,K,J,O,E,B,G,D,A,N=this;console.log("it's a file upload");G=F.serializeArray();for(L=0,O=G.length;L<O;L++){H=G[L];if((H.value!=null)&&jQuery.trim(H.value).length>0){C[H.name]=H.value}}Q=new FormData();D=this.model.parameters;for(K=0,E=D.length;K<E;K++){I=D[K];if(I.paramType==="form"){Q.append(I.name,C[I.name])}}P={};A=this.model.parameters;for(J=0,B=A.length;J<B;J++){I=A[J];if(I.paramType==="header"){P[I.name]=C[I.name]}}console.log(P);$.each($('input[type~="file"]'),function(R,S){return Q.append($(S).attr("name"),S.files[0])});console.log(Q);this.invocationUrl=this.model.supportHeaderParams()?(P=this.model.getHeaderParams(C),this.model.urlify(C,false)):this.model.urlify(C,true);$(".request_url",$(this.el)).html("<pre>"+this.invocationUrl+"</pre>");M={type:this.model.method,url:this.invocationUrl,headers:P,data:Q,dataType:"json",contentType:false,processData:false,error:function(S,T,R){return N.showErrorStatus(N.wrap(S),N)},success:function(R){return N.showResponse(R,N)},complete:function(R){return N.showCompleteStatus(N.wrap(R),N)}};if(window.authorizations){window.authorizations.apply(M)}jQuery.ajax(M);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;F<B;F++){D=E[F];if(D.selected){C.push(D.value)}}if(C.length>0){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,"<br>");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?X<Y:X>Y;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<K;E++){J=N[E];F(J)}return G};y.prototype.showStatus=function(D){var C,B,G,F,E,A;B=D.content.data;F=D.getHeaders();G=F["Content-Type"];if(B===void 0){C=$("<code />").text("no content");E=$('<pre class="json" />').append(C)}else{if(G.indexOf("application/json")===0||G.indexOf("application/hal+json")===0){C=$("<code />").text(JSON.stringify(JSON.parse(B),null,2));E=$('<pre class="json" />').append(C)}else{if(G.indexOf("application/xml")===0){C=$("<code />").text(this.formatXml(B));E=$('<pre class="xml" />').append(C)}else{if(G.indexOf("text/html")===0){C=$("<code />").html(B);E=$('<pre class="xml" />').append(C)}else{if(G.indexOf("image/")===0){E=$("<img>").attr("src",D.request.url)}else{C=$("<code />").text(B);E=$('<pre class="json" />').append(C)}}}}}A=E;$(".request_url",$(this.el)).html("<pre>"+D.request.url+"</pre>");$(".response_code",$(this.el)).html("<pre>"+D.status+"</pre>");$(".response_body",$(this.el)).html(A);$(".response_headers",$(this.el)).html("<pre>"+JSON.stringify(D.getHeaders(),null," ").replace(/\n/g,"<br>")+"</pre>");$(".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);
@@ -1,112 +1,192 @@
1
- // Generated by CoffeeScript 1.4.0
1
+ // Generated by CoffeeScript 1.6.3
2
2
  (function() {
3
- var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
3
+ var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
4
4
  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
5
5
 
6
6
  SwaggerApi = (function() {
7
-
8
- SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
7
+ SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
9
8
 
10
9
  SwaggerApi.prototype.debug = false;
11
10
 
12
- SwaggerApi.prototype.api_key = null;
13
-
14
11
  SwaggerApi.prototype.basePath = null;
15
12
 
16
- function SwaggerApi(options) {
13
+ SwaggerApi.prototype.authorizations = null;
14
+
15
+ SwaggerApi.prototype.authorizationScheme = null;
16
+
17
+ SwaggerApi.prototype.info = null;
18
+
19
+ function SwaggerApi(url, options) {
17
20
  if (options == null) {
18
21
  options = {};
19
22
  }
20
- if (options.discoveryUrl != null) {
21
- this.discoveryUrl = options.discoveryUrl;
22
- }
23
- if (options.debug != null) {
24
- this.debug = options.debug;
25
- }
26
- this.apiKeyName = options.apiKeyName != null ? options.apiKeyName : 'api_key';
27
- if (options.apiKey != null) {
28
- this.api_key = options.apiKey;
29
- }
30
- if (options.api_key != null) {
31
- this.api_key = options.api_key;
23
+ if (url) {
24
+ if (url.url) {
25
+ options = url;
26
+ } else {
27
+ this.url = url;
28
+ }
29
+ } else {
30
+ options = url;
32
31
  }
33
- if (options.verbose != null) {
34
- this.verbose = options.verbose;
32
+ if (options.url != null) {
33
+ this.url = options.url;
35
34
  }
36
- this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
37
- this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
38
35
  if (options.success != null) {
39
36
  this.success = options.success;
40
37
  }
41
38
  this.failure = options.failure != null ? options.failure : function() {};
42
39
  this.progress = options.progress != null ? options.progress : function() {};
43
- this.headers = options.headers != null ? options.headers : {};
44
- this.booleanValues = options.booleanValues != null ? options.booleanValues : new Array('true', 'false');
45
- this.discoveryUrl = this.suffixApiKey(this.discoveryUrl);
46
40
  if (options.success != null) {
47
41
  this.build();
48
42
  }
49
43
  }
50
44
 
51
45
  SwaggerApi.prototype.build = function() {
52
- var _this = this;
53
- this.progress('fetching resource list: ' + this.discoveryUrl);
54
- return jQuery.getJSON(this.discoveryUrl, function(response) {
55
- var res, resource, _i, _j, _len, _len1, _ref, _ref1;
56
- if (response.apiVersion != null) {
57
- _this.apiVersion = response.apiVersion;
58
- }
59
- if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
60
- _this.basePath = response.basePath;
61
- if (_this.basePath.match(/^HTTP/i) == null) {
62
- _this.fail("discoveryUrl basePath must be a URL.");
63
- }
64
- _this.basePath = _this.basePath.replace(/\/$/, '');
65
- } else {
66
- _this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/'));
67
- log('derived basepath from discoveryUrl as ' + _this.basePath);
68
- }
69
- _this.apis = {};
70
- _this.apisArray = [];
71
- if (response.resourcePath != null) {
72
- _this.resourcePath = response.resourcePath;
73
- res = null;
74
- _ref = response.apis;
75
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
76
- resource = _ref[_i];
77
- if (res === null) {
78
- res = new SwaggerResource(resource, _this);
46
+ var e, obj,
47
+ _this = this;
48
+ this.progress('fetching resource list: ' + this.url);
49
+ obj = {
50
+ url: this.url,
51
+ method: "get",
52
+ headers: {},
53
+ on: {
54
+ error: function(response) {
55
+ if (_this.url.substring(0, 4) !== 'http') {
56
+ return _this.fail('Please specify the protocol for ' + _this.url);
57
+ } else if (response.status === 0) {
58
+ return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
59
+ } else if (response.status === 404) {
60
+ return _this.fail('Can\'t read swagger JSON from ' + _this.url);
79
61
  } else {
80
- res.addOperations(resource.path, resource.operations);
62
+ return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
63
+ }
64
+ },
65
+ response: function(rawResponse) {
66
+ var response;
67
+ response = JSON.parse(rawResponse.content.data);
68
+ _this.swaggerVersion = response.swaggerVersion;
69
+ if (_this.swaggerVersion === "1.2") {
70
+ return _this.buildFromSpec(response);
71
+ } else {
72
+ return _this.buildFrom1_1Spec(response);
81
73
  }
82
74
  }
83
- if (res != null) {
84
- _this.apis[res.name] = res;
85
- _this.apisArray.push(res);
86
- res.ready = true;
87
- _this.selfReflect();
75
+ }
76
+ };
77
+ e = {};
78
+ if (typeof window !== 'undefined') {
79
+ e = window;
80
+ } else {
81
+ e = exports;
82
+ }
83
+ e.authorizations.apply(obj);
84
+ new SwaggerHttp().execute(obj);
85
+ return this;
86
+ };
87
+
88
+ SwaggerApi.prototype.buildFromSpec = function(response) {
89
+ var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
90
+ if (response.apiVersion != null) {
91
+ this.apiVersion = response.apiVersion;
92
+ }
93
+ this.apis = {};
94
+ this.apisArray = [];
95
+ this.produces = response.produces;
96
+ this.authSchemes = response.authorizations;
97
+ if (response.info != null) {
98
+ this.info = response.info;
99
+ }
100
+ isApi = false;
101
+ _ref = response.apis;
102
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
103
+ api = _ref[_i];
104
+ if (api.operations) {
105
+ _ref1 = api.operations;
106
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
107
+ operation = _ref1[_j];
108
+ isApi = true;
88
109
  }
89
- } else {
90
- _ref1 = response.apis;
110
+ }
111
+ }
112
+ if (response.basePath) {
113
+ this.basePath = response.basePath;
114
+ } else if (this.url.indexOf('?') > 0) {
115
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
116
+ } else {
117
+ this.basePath = this.url;
118
+ }
119
+ if (isApi) {
120
+ newName = response.resourcePath.replace(/\//g, '');
121
+ this.resourcePath = response.resourcePath;
122
+ res = new SwaggerResource(response, this);
123
+ this.apis[newName] = res;
124
+ this.apisArray.push(res);
125
+ } else {
126
+ _ref2 = response.apis;
127
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
128
+ resource = _ref2[_k];
129
+ res = new SwaggerResource(resource, this);
130
+ this.apis[res.name] = res;
131
+ this.apisArray.push(res);
132
+ }
133
+ }
134
+ if (this.success) {
135
+ this.success();
136
+ }
137
+ return this;
138
+ };
139
+
140
+ SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
141
+ var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
142
+ console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
143
+ if (response.apiVersion != null) {
144
+ this.apiVersion = response.apiVersion;
145
+ }
146
+ this.apis = {};
147
+ this.apisArray = [];
148
+ this.produces = response.produces;
149
+ if (response.info != null) {
150
+ this.info = response.info;
151
+ }
152
+ isApi = false;
153
+ _ref = response.apis;
154
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
155
+ api = _ref[_i];
156
+ if (api.operations) {
157
+ _ref1 = api.operations;
91
158
  for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
92
- resource = _ref1[_j];
93
- res = new SwaggerResource(resource, _this);
94
- _this.apis[res.name] = res;
95
- _this.apisArray.push(res);
159
+ operation = _ref1[_j];
160
+ isApi = true;
96
161
  }
97
162
  }
98
- return _this;
99
- }).error(function(error) {
100
- if (_this.discoveryUrl.substring(0, 4) !== 'http') {
101
- return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
102
- } else if (error.status === 0) {
103
- return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
104
- } else if (error.status === 404) {
105
- return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
106
- } else {
107
- return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
163
+ }
164
+ if (response.basePath) {
165
+ this.basePath = response.basePath;
166
+ } else if (this.url.indexOf('?') > 0) {
167
+ this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
168
+ } else {
169
+ this.basePath = this.url;
170
+ }
171
+ if (isApi) {
172
+ newName = response.resourcePath.replace(/\//g, '');
173
+ this.resourcePath = response.resourcePath;
174
+ res = new SwaggerResource(response, this);
175
+ this.apis[newName] = res;
176
+ this.apisArray.push(res);
177
+ } else {
178
+ _ref2 = response.apis;
179
+ for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
180
+ resource = _ref2[_k];
181
+ res = new SwaggerResource(resource, this);
182
+ this.apis[res.name] = res;
183
+ this.apisArray.push(res);
108
184
  }
109
- });
185
+ }
186
+ if (this.success) {
187
+ this.success();
188
+ }
189
+ return this;
110
190
  };
111
191
 
112
192
  SwaggerApi.prototype.selfReflect = function() {
@@ -141,7 +221,7 @@
141
221
  for (resource_name in _ref) {
142
222
  resource = _ref[resource_name];
143
223
  for (modelName in resource.models) {
144
- if (!(this.models[modelName] != null)) {
224
+ if (this.models[modelName] == null) {
145
225
  this.models[modelName] = resource.models[modelName];
146
226
  this.modelsArray.push(resource.models[modelName]);
147
227
  }
@@ -156,16 +236,6 @@
156
236
  return _results;
157
237
  };
158
238
 
159
- SwaggerApi.prototype.suffixApiKey = function(url) {
160
- var sep;
161
- if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
162
- sep = url.indexOf('?') > 0 ? '&' : '?';
163
- return url + sep + this.apiKeyName + '=' + this.api_key;
164
- } else {
165
- return url;
166
- }
167
- };
168
-
169
239
  SwaggerApi.prototype.help = function() {
170
240
  var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
171
241
  _ref = this.apis;
@@ -191,11 +261,19 @@
191
261
  })();
192
262
 
193
263
  SwaggerResource = (function() {
264
+ SwaggerResource.prototype.api = null;
265
+
266
+ SwaggerResource.prototype.produces = null;
267
+
268
+ SwaggerResource.prototype.consumes = null;
194
269
 
195
270
  function SwaggerResource(resourceObj, api) {
196
- var parts,
271
+ var consumes, e, obj, parts, produces,
197
272
  _this = this;
198
273
  this.api = api;
274
+ this.api = this.api;
275
+ produces = [];
276
+ consumes = [];
199
277
  this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
200
278
  this.description = resourceObj.description;
201
279
  parts = this.path.split("/");
@@ -205,45 +283,73 @@
205
283
  this.operationsArray = [];
206
284
  this.modelsArray = [];
207
285
  this.models = {};
208
- if ((resourceObj.operations != null) && (this.api.resourcePath != null)) {
209
- this.api.progress('reading resource ' + this.name + ' models and operations');
210
- this.addModels(resourceObj.models);
211
- this.addOperations(resourceObj.path, resourceObj.operations);
212
- this.api[this.name] = this;
286
+ if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
287
+ this.addApiDeclaration(resourceObj);
213
288
  } else {
214
289
  if (this.path == null) {
215
290
  this.api.fail("SwaggerResources must have a path.");
216
291
  }
217
- this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
292
+ if (this.path.substring(0, 4) === 'http') {
293
+ this.url = this.path.replace('{format}', 'json');
294
+ } else {
295
+ this.url = this.api.basePath + this.path.replace('{format}', 'json');
296
+ }
218
297
  this.api.progress('fetching resource ' + this.name + ': ' + this.url);
219
- jQuery.getJSON(this.url, function(response) {
220
- var endpoint, _i, _len, _ref;
221
- if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
222
- _this.basePath = response.basePath;
223
- _this.basePath = _this.basePath.replace(/\/$/, '');
224
- }
225
- _this.addModels(response.models);
226
- if (response.apis) {
227
- _ref = response.apis;
228
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
229
- endpoint = _ref[_i];
230
- _this.addOperations(endpoint.path, endpoint.operations);
298
+ obj = {
299
+ url: this.url,
300
+ method: "get",
301
+ headers: {},
302
+ on: {
303
+ error: function(response) {
304
+ return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
305
+ },
306
+ response: function(rawResponse) {
307
+ var response;
308
+ response = JSON.parse(rawResponse.content.data);
309
+ return _this.addApiDeclaration(response);
231
310
  }
232
311
  }
233
- _this.api[_this.name] = _this;
234
- _this.ready = true;
235
- return _this.api.selfReflect();
236
- }).error(function(error) {
237
- return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
238
- });
312
+ };
313
+ e = {};
314
+ if (typeof window !== 'undefined') {
315
+ e = window;
316
+ } else {
317
+ e = exports;
318
+ }
319
+ e.authorizations.apply(obj);
320
+ new SwaggerHttp().execute(obj);
239
321
  }
240
322
  }
241
323
 
324
+ SwaggerResource.prototype.addApiDeclaration = function(response) {
325
+ var endpoint, _i, _len, _ref;
326
+ if (response.produces != null) {
327
+ this.produces = response.produces;
328
+ }
329
+ if (response.consumes != null) {
330
+ this.consumes = response.consumes;
331
+ }
332
+ if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0) {
333
+ this.basePath = response.basePath;
334
+ }
335
+ this.addModels(response.models);
336
+ if (response.apis) {
337
+ _ref = response.apis;
338
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
339
+ endpoint = _ref[_i];
340
+ this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
341
+ }
342
+ }
343
+ this.api[this.name] = this;
344
+ this.ready = true;
345
+ return this.api.selfReflect();
346
+ };
347
+
242
348
  SwaggerResource.prototype.addModels = function(models) {
243
349
  var model, modelName, swaggerModel, _i, _len, _ref, _results;
244
350
  if (models != null) {
245
351
  for (modelName in models) {
246
- if (!(this.models[modelName] != null)) {
352
+ if (this.models[modelName] == null) {
247
353
  swaggerModel = new SwaggerModel(modelName, models[modelName]);
248
354
  this.modelsArray.push(swaggerModel);
249
355
  this.models[modelName] = swaggerModel;
@@ -259,17 +365,50 @@
259
365
  }
260
366
  };
261
367
 
262
- SwaggerResource.prototype.addOperations = function(resource_path, ops) {
263
- var consumes, o, op, _i, _len, _results;
368
+ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
369
+ var method, o, op, r, ref, responseMessages, type, _i, _j, _len, _len1, _results;
264
370
  if (ops) {
265
371
  _results = [];
266
372
  for (_i = 0, _len = ops.length; _i < _len; _i++) {
267
373
  o = ops[_i];
268
- consumes = o.consumes;
374
+ consumes = this.consumes;
375
+ produces = this.produces;
376
+ if (o.consumes != null) {
377
+ consumes = o.consumes;
378
+ } else {
379
+ consumes = this.consumes;
380
+ }
381
+ if (o.produces != null) {
382
+ produces = o.produces;
383
+ } else {
384
+ produces = this.produces;
385
+ }
386
+ type = o.type || o.responseClass;
387
+ if (type === "array") {
388
+ ref = null;
389
+ if (o.items) {
390
+ ref = o.items["type"] || o.items["$ref"];
391
+ }
392
+ type = "array[" + ref + "]";
393
+ }
394
+ responseMessages = o.responseMessages;
395
+ method = o.method;
396
+ if (o.httpMethod) {
397
+ method = o.httpMethod;
398
+ }
269
399
  if (o.supportedContentTypes) {
270
400
  consumes = o.supportedContentTypes;
271
401
  }
272
- op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.consumes, o.produces);
402
+ if (o.errorResponses) {
403
+ responseMessages = o.errorResponses;
404
+ for (_j = 0, _len1 = responseMessages.length; _j < _len1; _j++) {
405
+ r = responseMessages[_j];
406
+ r.message = r.reason;
407
+ r.reason = null;
408
+ }
409
+ }
410
+ o.nickname = this.sanitize(o.nickname);
411
+ op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces);
273
412
  this.operations[op.nickname] = op;
274
413
  _results.push(this.operationsArray.push(op));
275
414
  }
@@ -277,19 +416,30 @@
277
416
  }
278
417
  };
279
418
 
419
+ SwaggerResource.prototype.sanitize = function(nickname) {
420
+ var op;
421
+ op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_');
422
+ op = op.replace(/((_){2,})/g, '_');
423
+ op = op.replace(/^(_)*/g, '');
424
+ op = op.replace(/([_])*$/g, '');
425
+ return op;
426
+ };
427
+
280
428
  SwaggerResource.prototype.help = function() {
281
- var operation, operation_name, parameter, _i, _len, _ref, _ref1;
429
+ var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results;
282
430
  _ref = this.operations;
431
+ _results = [];
283
432
  for (operation_name in _ref) {
284
433
  operation = _ref[operation_name];
285
- console.log(" " + operation.nickname);
434
+ msg = " " + operation.nickname;
286
435
  _ref1 = operation.parameters;
287
436
  for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
288
437
  parameter = _ref1[_i];
289
- console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
438
+ msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
290
439
  }
440
+ _results.push(msg);
291
441
  }
292
- return this;
442
+ return _results;
293
443
  };
294
444
 
295
445
  return SwaggerResource;
@@ -297,24 +447,32 @@
297
447
  })();
298
448
 
299
449
  SwaggerModel = (function() {
300
-
301
450
  function SwaggerModel(modelName, obj) {
302
- var propertyName;
451
+ var prop, propertyName, value;
303
452
  this.name = obj.id != null ? obj.id : modelName;
304
453
  this.properties = [];
305
454
  for (propertyName in obj.properties) {
306
- this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
455
+ if (obj.required != null) {
456
+ for (value in obj.required) {
457
+ if (propertyName === obj.required[value]) {
458
+ obj.properties[propertyName].required = true;
459
+ }
460
+ }
461
+ }
462
+ prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]);
463
+ this.properties.push(prop);
307
464
  }
308
465
  }
309
466
 
310
467
  SwaggerModel.prototype.setReferencedModels = function(allModels) {
311
- var prop, _i, _len, _ref, _results;
468
+ var prop, type, _i, _len, _ref, _results;
312
469
  _ref = this.properties;
313
470
  _results = [];
314
471
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
315
472
  prop = _ref[_i];
316
- if (allModels[prop.dataType] != null) {
317
- _results.push(prop.refModel = allModels[prop.dataType]);
473
+ type = prop.type || prop.dataType;
474
+ if (allModels[type] != null) {
475
+ _results.push(prop.refModel = allModels[type]);
318
476
  } else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) {
319
477
  _results.push(prop.refModel = allModels[prop.refDataType]);
320
478
  } else {
@@ -324,7 +482,7 @@
324
482
  return _results;
325
483
  };
326
484
 
327
- SwaggerModel.prototype.getMockSignature = function(prefix, modelsToIgnore) {
485
+ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
328
486
  var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
329
487
  propertiesStr = [];
330
488
  _ref = this.properties;
@@ -332,15 +490,12 @@
332
490
  prop = _ref[_i];
333
491
  propertiesStr.push(prop.toString());
334
492
  }
335
- strong = '<span style="font-weight: bold; color: #000; font-size: 1.0em">';
336
- stronger = '<span style="font-weight: bold; color: #000; font-size: 1.1em">';
493
+ strong = '<span class="strong">';
494
+ stronger = '<span class="stronger">';
337
495
  strongClose = '</span>';
338
- classOpen = strong + 'class ' + this.name + '(' + strongClose;
339
- classClose = strong + ')' + strongClose;
340
- returnVal = classOpen + '<span>' + propertiesStr.join('</span>, <span>') + '</span>' + classClose;
341
- if (prefix != null) {
342
- returnVal = stronger + prefix + strongClose + '<br/>' + returnVal;
343
- }
496
+ classOpen = strong + this.name + ' {' + strongClose;
497
+ classClose = strong + '}' + strongClose;
498
+ returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
344
499
  if (!modelsToIgnore) {
345
500
  modelsToIgnore = [];
346
501
  }
@@ -349,20 +504,23 @@
349
504
  for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
350
505
  prop = _ref1[_j];
351
506
  if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
352
- returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(void 0, modelsToIgnore));
507
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
353
508
  }
354
509
  }
355
510
  return returnVal;
356
511
  };
357
512
 
358
- SwaggerModel.prototype.createJSONSample = function(modelToIgnore) {
513
+ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
359
514
  var prop, result, _i, _len, _ref;
360
515
  result = {};
516
+ modelsToIgnore = modelsToIgnore || [];
517
+ modelsToIgnore.push(this.name);
361
518
  _ref = this.properties;
362
519
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
363
520
  prop = _ref[_i];
364
- result[prop.name] = prop.getSampleValue(modelToIgnore);
521
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
365
522
  }
523
+ modelsToIgnore.pop(this.name);
366
524
  return result;
367
525
  };
368
526
 
@@ -371,12 +529,12 @@
371
529
  })();
372
530
 
373
531
  SwaggerModelProperty = (function() {
374
-
375
532
  function SwaggerModelProperty(name, obj) {
376
533
  this.name = name;
377
- this.dataType = obj.type;
378
- this.isArray = this.dataType.toLowerCase() === 'array';
534
+ this.dataType = obj.type || obj.dataType || obj["$ref"];
535
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
379
536
  this.descr = obj.description;
537
+ this.required = obj.required;
380
538
  if (obj.items != null) {
381
539
  if (obj.items.type != null) {
382
540
  this.refDataType = obj.items.type;
@@ -393,20 +551,27 @@
393
551
  this.valuesString = "'" + this.values.join("' or '") + "'";
394
552
  }
395
553
  }
554
+ if (obj["enum"] != null) {
555
+ this.valueType = "string";
556
+ this.values = obj["enum"];
557
+ if (this.values != null) {
558
+ this.valueString = "'" + this.values.join("' or '") + "'";
559
+ }
560
+ }
396
561
  }
397
562
 
398
- SwaggerModelProperty.prototype.getSampleValue = function(modelToIgnore) {
563
+ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
399
564
  var result;
400
- if ((this.refModel != null) && (!(this.refModel === modelToIgnore))) {
401
- result = this.refModel.createJSONSample(this.refModel);
565
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
566
+ result = this.refModel.createJSONSample(modelsToIgnore);
402
567
  } else {
403
- if (this.isArray) {
568
+ if (this.isCollection) {
404
569
  result = this.refDataType;
405
570
  } else {
406
571
  result = this.dataType;
407
572
  }
408
573
  }
409
- if (this.isArray) {
574
+ if (this.isCollection) {
410
575
  return [result];
411
576
  } else {
412
577
  return result;
@@ -414,13 +579,18 @@
414
579
  };
415
580
 
416
581
  SwaggerModelProperty.prototype.toString = function() {
417
- var str;
418
- str = this.name + ': ' + this.dataTypeWithRef;
582
+ var req, str;
583
+ req = this.required ? 'propReq' : 'propOpt';
584
+ str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
585
+ if (!this.required) {
586
+ str += ', <span class="propOptKey">optional</span>';
587
+ }
588
+ str += ')';
419
589
  if (this.values != null) {
420
- str += " = ['" + this.values.join("' or '") + "']";
590
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
421
591
  }
422
592
  if (this.descr != null) {
423
- str += ' {' + this.descr + '}';
593
+ str += ': <span class="propDesc">' + this.descr + '</span>';
424
594
  }
425
595
  return str;
426
596
  };
@@ -430,54 +600,73 @@
430
600
  })();
431
601
 
432
602
  SwaggerOperation = (function() {
433
-
434
- function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes, produces) {
435
- var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
603
+ function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
604
+ var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3,
436
605
  _this = this;
437
606
  this.nickname = nickname;
438
607
  this.path = path;
439
- this.httpMethod = httpMethod;
608
+ this.method = method;
440
609
  this.parameters = parameters != null ? parameters : [];
441
610
  this.summary = summary;
442
611
  this.notes = notes;
443
- this.responseClass = responseClass;
444
- this.errorResponses = errorResponses;
612
+ this.type = type;
613
+ this.responseMessages = responseMessages;
445
614
  this.resource = resource;
446
615
  this.consumes = consumes;
447
616
  this.produces = produces;
448
617
  this["do"] = __bind(this["do"], this);
449
-
450
618
  if (this.nickname == null) {
451
619
  this.resource.api.fail("SwaggerOperations must have a nickname.");
452
620
  }
453
621
  if (this.path == null) {
454
622
  this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
455
623
  }
456
- if (this.httpMethod == null) {
457
- this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
624
+ if (this.method == null) {
625
+ this.resource.api.fail("SwaggerOperation " + nickname + " is missing method.");
458
626
  }
459
627
  this.path = this.path.replace('{format}', 'json');
460
- this.httpMethod = this.httpMethod.toLowerCase();
461
- this.isGetMethod = this.httpMethod === "get";
628
+ this.method = this.method.toLowerCase();
629
+ this.isGetMethod = this.method === "get";
462
630
  this.resourceName = this.resource.name;
463
- if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
464
- this.responseClass = void 0;
631
+ if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
632
+ this.type = void 0;
465
633
  }
466
- if (this.responseClass != null) {
467
- this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
468
- this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
634
+ if (this.type != null) {
635
+ this.responseClassSignature = this.getSignature(this.type, this.resource.models);
636
+ this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
469
637
  }
470
- this.errorResponses = this.errorResponses || [];
638
+ this.responseMessages = this.responseMessages || [];
471
639
  _ref1 = this.parameters;
472
640
  for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
473
641
  parameter = _ref1[_i];
474
- parameter.name = parameter.name || parameter.dataType;
475
- if (parameter.dataType.toLowerCase() === 'boolean') {
642
+ parameter.name = parameter.name || parameter.type || parameter.dataType;
643
+ type = parameter.type || parameter.dataType;
644
+ if (type.toLowerCase() === 'boolean') {
476
645
  parameter.allowableValues = {};
477
- parameter.allowableValues.values = this.resource.api.booleanValues;
646
+ parameter.allowableValues.values = ["true", "false"];
647
+ }
648
+ parameter.signature = this.getSignature(type, this.resource.models);
649
+ parameter.sampleJSON = this.getSampleJSON(type, this.resource.models);
650
+ if (parameter["enum"] != null) {
651
+ parameter.isList = true;
652
+ parameter.allowableValues = {};
653
+ parameter.allowableValues.descriptiveValues = [];
654
+ _ref2 = parameter["enum"];
655
+ for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
656
+ v = _ref2[_j];
657
+ if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
658
+ parameter.allowableValues.descriptiveValues.push({
659
+ value: v,
660
+ isDefault: true
661
+ });
662
+ } else {
663
+ parameter.allowableValues.descriptiveValues.push({
664
+ value: v,
665
+ isDefault: false
666
+ });
667
+ }
668
+ }
478
669
  }
479
- parameter.signature = this.getSignature(parameter.dataType, this.resource.models);
480
- parameter.sampleJSON = this.getSampleJSON(parameter.dataType, this.resource.models);
481
670
  if (parameter.allowableValues != null) {
482
671
  if (parameter.allowableValues.valueType === "RANGE") {
483
672
  parameter.isRange = true;
@@ -486,9 +675,9 @@
486
675
  }
487
676
  if (parameter.allowableValues.values != null) {
488
677
  parameter.allowableValues.descriptiveValues = [];
489
- _ref2 = parameter.allowableValues.values;
490
- for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
491
- v = _ref2[_j];
678
+ _ref3 = parameter.allowableValues.values;
679
+ for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) {
680
+ v = _ref3[_k];
492
681
  if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
493
682
  parameter.allowableValues.descriptiveValues.push({
494
683
  value: v,
@@ -507,52 +696,64 @@
507
696
  this.resource[this.nickname] = function(args, callback, error) {
508
697
  return _this["do"](args, callback, error);
509
698
  };
699
+ this.resource[this.nickname].help = function() {
700
+ return _this.help();
701
+ };
510
702
  }
511
703
 
512
- SwaggerOperation.prototype.isListType = function(dataType) {
513
- if (dataType.indexOf('[') >= 0) {
514
- return dataType.substring(dataType.indexOf('[') + 1, dataType.indexOf(']'));
704
+ SwaggerOperation.prototype.isListType = function(type) {
705
+ if (type.indexOf('[') >= 0) {
706
+ return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
515
707
  } else {
516
708
  return void 0;
517
709
  }
518
710
  };
519
711
 
520
- SwaggerOperation.prototype.getSignature = function(dataType, models) {
712
+ SwaggerOperation.prototype.getSignature = function(type, models) {
521
713
  var isPrimitive, listType;
522
- listType = this.isListType(dataType);
523
- isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true;
714
+ listType = this.isListType(type);
715
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
524
716
  if (isPrimitive) {
525
- return dataType;
717
+ return type;
526
718
  } else {
527
719
  if (listType != null) {
528
- return models[listType].getMockSignature(dataType);
720
+ return models[listType].getMockSignature();
529
721
  } else {
530
- return models[dataType].getMockSignature(dataType);
722
+ return models[type].getMockSignature();
531
723
  }
532
724
  }
533
725
  };
534
726
 
535
- SwaggerOperation.prototype.getSampleJSON = function(dataType, models) {
727
+ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
536
728
  var isPrimitive, listType, val;
537
- listType = this.isListType(dataType);
538
- isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true;
539
- val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[dataType].createJSONSample());
729
+ listType = this.isListType(type);
730
+ isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true;
731
+ val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
540
732
  if (val) {
541
733
  val = listType ? [val] : val;
542
734
  return JSON.stringify(val, null, 2);
543
735
  }
544
736
  };
545
737
 
546
- SwaggerOperation.prototype["do"] = function(args, callback, error) {
547
- var body, headers;
738
+ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) {
739
+ var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref;
548
740
  if (args == null) {
549
741
  args = {};
550
742
  }
743
+ if (opts == null) {
744
+ opts = {};
745
+ }
746
+ requestContentType = null;
747
+ responseContentType = null;
551
748
  if ((typeof args) === "function") {
552
- error = callback;
749
+ error = opts;
553
750
  callback = args;
554
751
  args = {};
555
752
  }
753
+ if ((typeof opts) === "function") {
754
+ error = callback;
755
+ callback = opts;
756
+ }
556
757
  if (error == null) {
557
758
  error = function(xhr, textStatus, error) {
558
759
  return console.log(xhr, textStatus, error);
@@ -560,18 +761,61 @@
560
761
  }
561
762
  if (callback == null) {
562
763
  callback = function(data) {
563
- return console.log(data);
764
+ var content;
765
+ content = null;
766
+ if (data.content != null) {
767
+ content = data.content.data;
768
+ } else {
769
+ content = "no data";
770
+ }
771
+ return console.log("default callback: " + content);
564
772
  };
565
773
  }
774
+ params = {};
775
+ params.headers = [];
566
776
  if (args.headers != null) {
567
- headers = args.headers;
777
+ params.headers = args.headers;
568
778
  delete args.headers;
569
779
  }
780
+ _ref = this.parameters;
781
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
782
+ param = _ref[_i];
783
+ if (param.paramType === "header") {
784
+ if (args[param.name]) {
785
+ params.headers[param.name] = args[param.name];
786
+ }
787
+ }
788
+ }
570
789
  if (args.body != null) {
571
- body = args.body;
790
+ params.body = args.body;
572
791
  delete args.body;
573
792
  }
574
- return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
793
+ possibleParams = (function() {
794
+ var _j, _len1, _ref1, _results;
795
+ _ref1 = this.parameters;
796
+ _results = [];
797
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
798
+ param = _ref1[_j];
799
+ if (param.paramType === "form" || param.paramType.toLowerCase() === "file") {
800
+ _results.push(param);
801
+ }
802
+ }
803
+ return _results;
804
+ }).call(this);
805
+ if (possibleParams) {
806
+ for (key in possibleParams) {
807
+ value = possibleParams[key];
808
+ if (args[value.name]) {
809
+ params[value.name] = args[value.name];
810
+ }
811
+ }
812
+ }
813
+ req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this);
814
+ if (opts.mock != null) {
815
+ return req;
816
+ } else {
817
+ return true;
818
+ }
575
819
  };
576
820
 
577
821
  SwaggerOperation.prototype.pathJson = function() {
@@ -582,11 +826,8 @@
582
826
  return this.path.replace("{format}", "xml");
583
827
  };
584
828
 
585
- SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
586
- var param, queryParams, reg, url, _i, _len, _ref;
587
- if (includeApiKey == null) {
588
- includeApiKey = true;
589
- }
829
+ SwaggerOperation.prototype.urlify = function(args) {
830
+ var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1;
590
831
  url = this.resource.basePath + this.pathJson();
591
832
  _ref = this.parameters;
592
833
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -601,13 +842,18 @@
601
842
  }
602
843
  }
603
844
  }
604
- if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
605
- args[this.apiKeyName] = this.resource.api.api_key;
606
- }
607
- if (this.supportHeaderParams()) {
608
- queryParams = jQuery.param(this.getQueryParams(args, includeApiKey));
609
- } else {
610
- queryParams = jQuery.param(this.getQueryAndHeaderParams(args, includeApiKey));
845
+ queryParams = "";
846
+ _ref1 = this.parameters;
847
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
848
+ param = _ref1[_j];
849
+ if (param.paramType === 'query') {
850
+ if (args[param.name]) {
851
+ if (queryParams !== "") {
852
+ queryParams += "&";
853
+ }
854
+ queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
855
+ }
856
+ }
611
857
  }
612
858
  if ((queryParams != null) && queryParams.length > 0) {
613
859
  url += "?" + queryParams;
@@ -623,58 +869,44 @@
623
869
  return this.resource.api.supportedSubmitMethods;
624
870
  };
625
871
 
626
- SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
627
- if (includeApiKey == null) {
628
- includeApiKey = true;
629
- }
630
- return this.getMatchingParams(['query', 'header'], args, includeApiKey);
872
+ SwaggerOperation.prototype.getQueryParams = function(args) {
873
+ return this.getMatchingParams(['query'], args);
631
874
  };
632
875
 
633
- SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
634
- if (includeApiKey == null) {
635
- includeApiKey = true;
636
- }
637
- return this.getMatchingParams(['query'], args, includeApiKey);
876
+ SwaggerOperation.prototype.getHeaderParams = function(args) {
877
+ return this.getMatchingParams(['header'], args);
638
878
  };
639
879
 
640
- SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) {
641
- if (includeApiKey == null) {
642
- includeApiKey = true;
643
- }
644
- return this.getMatchingParams(['header'], args, includeApiKey);
645
- };
646
-
647
- SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey) {
880
+ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) {
648
881
  var matchingParams, name, param, value, _i, _len, _ref, _ref1;
649
882
  matchingParams = {};
650
883
  _ref = this.parameters;
651
884
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
652
885
  param = _ref[_i];
653
- if ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) {
886
+ if (args && args[param.name]) {
654
887
  matchingParams[param.name] = args[param.name];
655
888
  }
656
889
  }
657
- if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
658
- matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key;
659
- }
660
- if (jQuery.inArray('header', paramTypes) >= 0) {
661
- _ref1 = this.resource.api.headers;
662
- for (name in _ref1) {
663
- value = _ref1[name];
664
- matchingParams[name] = value;
665
- }
890
+ _ref1 = this.resource.api.headers;
891
+ for (name in _ref1) {
892
+ value = _ref1[name];
893
+ matchingParams[name] = value;
666
894
  }
667
895
  return matchingParams;
668
896
  };
669
897
 
670
898
  SwaggerOperation.prototype.help = function() {
671
- var parameter, _i, _len, _ref;
899
+ var msg, parameter, _i, _len, _ref;
900
+ msg = "";
672
901
  _ref = this.parameters;
673
902
  for (_i = 0, _len = _ref.length; _i < _len; _i++) {
674
903
  parameter = _ref[_i];
675
- console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
904
+ if (msg !== "") {
905
+ msg += "\n";
906
+ }
907
+ msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description;
676
908
  }
677
- return this;
909
+ return msg;
678
910
  };
679
911
 
680
912
  return SwaggerOperation;
@@ -682,17 +914,17 @@
682
914
  })();
683
915
 
684
916
  SwaggerRequest = (function() {
685
-
686
- function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
687
- var obj,
917
+ function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) {
918
+ var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values,
688
919
  _this = this;
689
920
  this.type = type;
690
921
  this.url = url;
691
- this.headers = headers;
692
- this.body = body;
922
+ this.params = params;
923
+ this.opts = opts;
693
924
  this.successCallback = successCallback;
694
925
  this.errorCallback = errorCallback;
695
926
  this.operation = operation;
927
+ this.execution = execution;
696
928
  if (this.type == null) {
697
929
  throw "SwaggerRequest type is required (get/post/put/delete).";
698
930
  }
@@ -708,30 +940,147 @@
708
940
  if (this.operation == null) {
709
941
  throw "SwaggerRequest operation is required.";
710
942
  }
711
- if (this.operation.resource.api.verbose) {
712
- console.log(this.asCurl());
943
+ this.type = this.type.toUpperCase();
944
+ headers = params.headers;
945
+ myHeaders = {};
946
+ body = params.body;
947
+ parent = params["parent"];
948
+ requestContentType = "application/json";
949
+ if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) {
950
+ if (this.opts.requestContentType) {
951
+ requestContentType = this.opts.requestContentType;
952
+ }
953
+ } else {
954
+ if (((function() {
955
+ var _i, _len, _ref, _results;
956
+ _ref = this.operation.parameters;
957
+ _results = [];
958
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
959
+ param = _ref[_i];
960
+ if (param.paramType === "form") {
961
+ _results.push(param);
962
+ }
963
+ }
964
+ return _results;
965
+ }).call(this)).length > 0) {
966
+ type = param.type || param.dataType;
967
+ if (((function() {
968
+ var _i, _len, _ref, _results;
969
+ _ref = this.operation.parameters;
970
+ _results = [];
971
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
972
+ param = _ref[_i];
973
+ if (type.toLowerCase() === "file") {
974
+ _results.push(param);
975
+ }
976
+ }
977
+ return _results;
978
+ }).call(this)).length > 0) {
979
+ requestContentType = "multipart/form-data";
980
+ } else {
981
+ requestContentType = "application/x-www-form-urlencoded";
982
+ }
983
+ } else if (this.type !== "DELETE") {
984
+ requestContentType = null;
985
+ }
986
+ }
987
+ if (requestContentType && this.operation.consumes) {
988
+ if (this.operation.consumes.indexOf(requestContentType) === -1) {
989
+ console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
990
+ if (this.requestContentType === null) {
991
+ requestContentType = this.operation.consumes[0];
992
+ }
993
+ }
994
+ }
995
+ responseContentType = null;
996
+ if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
997
+ if (this.opts.responseContentType) {
998
+ responseContentType = this.opts.responseContentType;
999
+ } else {
1000
+ responseContentType = "application/json";
1001
+ }
1002
+ } else {
1003
+ responseContentType = null;
1004
+ }
1005
+ if (responseContentType && this.operation.produces) {
1006
+ if (this.operation.produces.indexOf(responseContentType) === -1) {
1007
+ console.log("server can't produce " + responseContentType);
1008
+ }
1009
+ }
1010
+ if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
1011
+ fields = {};
1012
+ possibleParams = (function() {
1013
+ var _i, _len, _ref, _results;
1014
+ _ref = this.operation.parameters;
1015
+ _results = [];
1016
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
1017
+ param = _ref[_i];
1018
+ if (param.paramType === "form") {
1019
+ _results.push(param);
1020
+ }
1021
+ }
1022
+ return _results;
1023
+ }).call(this);
1024
+ values = {};
1025
+ for (key in possibleParams) {
1026
+ value = possibleParams[key];
1027
+ if (this.params[value.name]) {
1028
+ values[value.name] = this.params[value.name];
1029
+ }
1030
+ }
1031
+ urlEncoded = "";
1032
+ for (key in values) {
1033
+ value = values[key];
1034
+ if (urlEncoded !== "") {
1035
+ urlEncoded += "&";
1036
+ }
1037
+ urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
1038
+ }
1039
+ body = urlEncoded;
1040
+ }
1041
+ for (name in headers) {
1042
+ myHeaders[name] = headers[name];
1043
+ }
1044
+ if (requestContentType) {
1045
+ myHeaders["Content-Type"] = requestContentType;
713
1046
  }
714
- this.headers || (this.headers = {});
715
- if (this.operation.resource.api.api_key != null) {
716
- this.headers[this.apiKeyName] = this.operation.resource.api.api_key;
1047
+ if (responseContentType) {
1048
+ myHeaders["Accept"] = responseContentType;
717
1049
  }
718
- if (this.headers.mock == null) {
1050
+ if (!((headers != null) && (headers.mock != null))) {
719
1051
  obj = {
720
- type: this.type,
721
1052
  url: this.url,
722
- data: JSON.stringify(this.body),
723
- dataType: 'json',
724
- error: function(xhr, textStatus, error) {
725
- return _this.errorCallback(xhr, textStatus, error);
726
- },
727
- success: function(data) {
728
- return _this.successCallback(data);
1053
+ method: this.type,
1054
+ headers: myHeaders,
1055
+ body: body,
1056
+ on: {
1057
+ error: function(response) {
1058
+ return _this.errorCallback(response, _this.opts.parent);
1059
+ },
1060
+ redirect: function(response) {
1061
+ return _this.successCallback(response, _this.opts.parent);
1062
+ },
1063
+ 307: function(response) {
1064
+ return _this.successCallback(response, _this.opts.parent);
1065
+ },
1066
+ response: function(response) {
1067
+ return _this.successCallback(response, _this.opts.parent);
1068
+ }
729
1069
  }
730
1070
  };
731
- if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
732
- obj.contentType = "application/json";
1071
+ e = {};
1072
+ if (typeof window !== 'undefined') {
1073
+ e = window;
1074
+ } else {
1075
+ e = exports;
1076
+ }
1077
+ e.authorizations.apply(obj);
1078
+ if (opts.mock == null) {
1079
+ new SwaggerHttp().execute(obj);
1080
+ } else {
1081
+ console.log(obj);
1082
+ return obj;
733
1083
  }
734
- jQuery.ajax(obj);
735
1084
  }
736
1085
  }
737
1086
 
@@ -754,12 +1103,142 @@
754
1103
 
755
1104
  })();
756
1105
 
757
- window.SwaggerApi = SwaggerApi;
1106
+ SwaggerHttp = (function() {
1107
+ SwaggerHttp.prototype.Shred = null;
1108
+
1109
+ SwaggerHttp.prototype.shred = null;
1110
+
1111
+ SwaggerHttp.prototype.content = null;
1112
+
1113
+ function SwaggerHttp() {
1114
+ var identity, toString,
1115
+ _this = this;
1116
+ if (typeof window !== 'undefined') {
1117
+ this.Shred = require("./shred");
1118
+ } else {
1119
+ this.Shred = require("shred");
1120
+ }
1121
+ this.shred = new this.Shred();
1122
+ identity = function(x) {
1123
+ return x;
1124
+ };
1125
+ toString = function(x) {
1126
+ return x.toString();
1127
+ };
1128
+ if (typeof window !== 'undefined') {
1129
+ this.content = require("./shred/content");
1130
+ this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1131
+ parser: identity,
1132
+ stringify: toString
1133
+ });
1134
+ } else {
1135
+ this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
1136
+ parser: identity,
1137
+ stringify: toString
1138
+ });
1139
+ }
1140
+ }
1141
+
1142
+ SwaggerHttp.prototype.execute = function(obj) {
1143
+ return this.shred.request(obj);
1144
+ };
1145
+
1146
+ return SwaggerHttp;
1147
+
1148
+ })();
1149
+
1150
+ SwaggerAuthorizations = (function() {
1151
+ SwaggerAuthorizations.prototype.authz = null;
1152
+
1153
+ function SwaggerAuthorizations() {
1154
+ this.authz = {};
1155
+ }
1156
+
1157
+ SwaggerAuthorizations.prototype.add = function(name, auth) {
1158
+ this.authz[name] = auth;
1159
+ return auth;
1160
+ };
1161
+
1162
+ SwaggerAuthorizations.prototype.apply = function(obj) {
1163
+ var key, value, _ref, _results;
1164
+ _ref = this.authz;
1165
+ _results = [];
1166
+ for (key in _ref) {
1167
+ value = _ref[key];
1168
+ _results.push(value.apply(obj));
1169
+ }
1170
+ return _results;
1171
+ };
1172
+
1173
+ return SwaggerAuthorizations;
1174
+
1175
+ })();
1176
+
1177
+ ApiKeyAuthorization = (function() {
1178
+ ApiKeyAuthorization.prototype.type = null;
1179
+
1180
+ ApiKeyAuthorization.prototype.name = null;
1181
+
1182
+ ApiKeyAuthorization.prototype.value = null;
1183
+
1184
+ function ApiKeyAuthorization(name, value, type) {
1185
+ this.name = name;
1186
+ this.value = value;
1187
+ this.type = type;
1188
+ }
1189
+
1190
+ ApiKeyAuthorization.prototype.apply = function(obj) {
1191
+ if (this.type === "query") {
1192
+ if (obj.url.indexOf('?') > 0) {
1193
+ obj.url = obj.url + "&" + this.name + "=" + this.value;
1194
+ } else {
1195
+ obj.url = obj.url + "?" + this.name + "=" + this.value;
1196
+ }
1197
+ return true;
1198
+ } else if (this.type === "header") {
1199
+ return obj.headers[this.name] = this.value;
1200
+ }
1201
+ };
1202
+
1203
+ return ApiKeyAuthorization;
1204
+
1205
+ })();
1206
+
1207
+ PasswordAuthorization = (function() {
1208
+ PasswordAuthorization.prototype.name = null;
1209
+
1210
+ PasswordAuthorization.prototype.username = null;
1211
+
1212
+ PasswordAuthorization.prototype.password = null;
1213
+
1214
+ function PasswordAuthorization(name, username, password) {
1215
+ this.name = name;
1216
+ this.username = username;
1217
+ this.password = password;
1218
+ }
1219
+
1220
+ PasswordAuthorization.prototype.apply = function(obj) {
1221
+ return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password);
1222
+ };
1223
+
1224
+ return PasswordAuthorization;
1225
+
1226
+ })();
1227
+
1228
+ this.SwaggerApi = SwaggerApi;
1229
+
1230
+ this.SwaggerResource = SwaggerResource;
1231
+
1232
+ this.SwaggerOperation = SwaggerOperation;
1233
+
1234
+ this.SwaggerRequest = SwaggerRequest;
1235
+
1236
+ this.SwaggerModelProperty = SwaggerModelProperty;
758
1237
 
759
- window.SwaggerResource = SwaggerResource;
1238
+ this.ApiKeyAuthorization = ApiKeyAuthorization;
760
1239
 
761
- window.SwaggerOperation = SwaggerOperation;
1240
+ this.PasswordAuthorization = PasswordAuthorization;
762
1241
 
763
- window.SwaggerRequest = SwaggerRequest;
1242
+ this.authorizations = new SwaggerAuthorizations();
764
1243
 
765
1244
  }).call(this);