grape-swagger-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +2 -2
- data/app/assets/images/grape_swagger_rails/logo_small.png +0 -0
- data/app/assets/images/grape_swagger_rails/throbber.gif +0 -0
- data/app/assets/javascripts/grape_swagger_rails/application.js +22 -0
- data/app/assets/javascripts/grape_swagger_rails/backbone-min.js +38 -0
- data/app/assets/javascripts/grape_swagger_rails/handlebars-1.0.rc.1.js +1920 -0
- data/app/assets/javascripts/grape_swagger_rails/highlight.7.3.pack.js +1 -0
- data/app/assets/javascripts/grape_swagger_rails/jquery-1.8.0.min.js +2 -0
- data/app/assets/javascripts/grape_swagger_rails/jquery.ba-bbq.min.js +18 -0
- data/app/assets/javascripts/grape_swagger_rails/jquery.slideto.min.js +1 -0
- data/app/assets/javascripts/grape_swagger_rails/jquery.wiggle.min.js +8 -0
- data/app/assets/javascripts/grape_swagger_rails/swagger-ui.js +1990 -0
- data/app/assets/javascripts/grape_swagger_rails/swagger-ui.min.js +1 -0
- data/app/assets/javascripts/grape_swagger_rails/swagger.js +765 -0
- data/app/assets/javascripts/grape_swagger_rails/underscore-min.js +32 -0
- data/app/assets/stylesheets/grape_swagger_rails/application.css +13 -0
- data/app/assets/stylesheets/grape_swagger_rails/hightlight.default.css +135 -0
- data/app/assets/stylesheets/grape_swagger_rails/screen.css +1759 -0
- data/app/controllers/grape_swagger_rails/application_controller.rb +8 -0
- data/app/views/grape_swagger_rails/application/index.html.erb +64 -0
- data/config/routes.rb +3 -0
- data/grape-swagger-rails.gemspec +9 -12
- data/lib/grape-swagger-rails.rb +4 -0
- data/lib/grape-swagger-rails/engine.rb +5 -0
- data/lib/grape-swagger-rails/version.rb +3 -0
- data/lib/script/rails +8 -0
- metadata +53 -15
- data/lib/generators/grape_swagger/install/install_generator.rb +0 -27
- data/lib/generators/grape_swagger/install/templates/general_api.rb +0 -10
- data/lib/grape/swagger/rails.rb +0 -9
- data/lib/grape/swagger/rails/version.rb +0 -7
@@ -0,0 +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);
|
@@ -0,0 +1,765 @@
|
|
1
|
+
// Generated by CoffeeScript 1.4.0
|
2
|
+
(function() {
|
3
|
+
var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
4
|
+
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
5
|
+
|
6
|
+
SwaggerApi = (function() {
|
7
|
+
|
8
|
+
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
9
|
+
|
10
|
+
SwaggerApi.prototype.debug = false;
|
11
|
+
|
12
|
+
SwaggerApi.prototype.api_key = null;
|
13
|
+
|
14
|
+
SwaggerApi.prototype.basePath = null;
|
15
|
+
|
16
|
+
function SwaggerApi(options) {
|
17
|
+
if (options == null) {
|
18
|
+
options = {};
|
19
|
+
}
|
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;
|
32
|
+
}
|
33
|
+
if (options.verbose != null) {
|
34
|
+
this.verbose = options.verbose;
|
35
|
+
}
|
36
|
+
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
|
37
|
+
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
|
38
|
+
if (options.success != null) {
|
39
|
+
this.success = options.success;
|
40
|
+
}
|
41
|
+
this.failure = options.failure != null ? options.failure : function() {};
|
42
|
+
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
|
+
if (options.success != null) {
|
47
|
+
this.build();
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
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);
|
79
|
+
} else {
|
80
|
+
res.addOperations(resource.path, resource.operations);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
if (res != null) {
|
84
|
+
_this.apis[res.name] = res;
|
85
|
+
_this.apisArray.push(res);
|
86
|
+
res.ready = true;
|
87
|
+
_this.selfReflect();
|
88
|
+
}
|
89
|
+
} else {
|
90
|
+
_ref1 = response.apis;
|
91
|
+
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);
|
96
|
+
}
|
97
|
+
}
|
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);
|
108
|
+
}
|
109
|
+
});
|
110
|
+
};
|
111
|
+
|
112
|
+
SwaggerApi.prototype.selfReflect = function() {
|
113
|
+
var resource, resource_name, _ref;
|
114
|
+
if (this.apis == null) {
|
115
|
+
return false;
|
116
|
+
}
|
117
|
+
_ref = this.apis;
|
118
|
+
for (resource_name in _ref) {
|
119
|
+
resource = _ref[resource_name];
|
120
|
+
if (resource.ready == null) {
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
this.setConsolidatedModels();
|
125
|
+
this.ready = true;
|
126
|
+
if (this.success != null) {
|
127
|
+
return this.success();
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
SwaggerApi.prototype.fail = function(message) {
|
132
|
+
this.failure(message);
|
133
|
+
throw message;
|
134
|
+
};
|
135
|
+
|
136
|
+
SwaggerApi.prototype.setConsolidatedModels = function() {
|
137
|
+
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
|
138
|
+
this.modelsArray = [];
|
139
|
+
this.models = {};
|
140
|
+
_ref = this.apis;
|
141
|
+
for (resource_name in _ref) {
|
142
|
+
resource = _ref[resource_name];
|
143
|
+
for (modelName in resource.models) {
|
144
|
+
if (!(this.models[modelName] != null)) {
|
145
|
+
this.models[modelName] = resource.models[modelName];
|
146
|
+
this.modelsArray.push(resource.models[modelName]);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
_ref1 = this.modelsArray;
|
151
|
+
_results = [];
|
152
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
153
|
+
model = _ref1[_i];
|
154
|
+
_results.push(model.setReferencedModels(this.models));
|
155
|
+
}
|
156
|
+
return _results;
|
157
|
+
};
|
158
|
+
|
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
|
+
SwaggerApi.prototype.help = function() {
|
170
|
+
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
|
171
|
+
_ref = this.apis;
|
172
|
+
for (resource_name in _ref) {
|
173
|
+
resource = _ref[resource_name];
|
174
|
+
console.log(resource_name);
|
175
|
+
_ref1 = resource.operations;
|
176
|
+
for (operation_name in _ref1) {
|
177
|
+
operation = _ref1[operation_name];
|
178
|
+
console.log(" " + operation.nickname);
|
179
|
+
_ref2 = operation.parameters;
|
180
|
+
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
181
|
+
parameter = _ref2[_i];
|
182
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
return this;
|
187
|
+
};
|
188
|
+
|
189
|
+
return SwaggerApi;
|
190
|
+
|
191
|
+
})();
|
192
|
+
|
193
|
+
SwaggerResource = (function() {
|
194
|
+
|
195
|
+
function SwaggerResource(resourceObj, api) {
|
196
|
+
var parts,
|
197
|
+
_this = this;
|
198
|
+
this.api = api;
|
199
|
+
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
200
|
+
this.description = resourceObj.description;
|
201
|
+
parts = this.path.split("/");
|
202
|
+
this.name = parts[parts.length - 1].replace('.{format}', '');
|
203
|
+
this.basePath = this.api.basePath;
|
204
|
+
this.operations = {};
|
205
|
+
this.operationsArray = [];
|
206
|
+
this.modelsArray = [];
|
207
|
+
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;
|
213
|
+
} else {
|
214
|
+
if (this.path == null) {
|
215
|
+
this.api.fail("SwaggerResources must have a path.");
|
216
|
+
}
|
217
|
+
this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
|
218
|
+
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);
|
231
|
+
}
|
232
|
+
}
|
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
|
+
});
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
SwaggerResource.prototype.addModels = function(models) {
|
243
|
+
var model, modelName, swaggerModel, _i, _len, _ref, _results;
|
244
|
+
if (models != null) {
|
245
|
+
for (modelName in models) {
|
246
|
+
if (!(this.models[modelName] != null)) {
|
247
|
+
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
248
|
+
this.modelsArray.push(swaggerModel);
|
249
|
+
this.models[modelName] = swaggerModel;
|
250
|
+
}
|
251
|
+
}
|
252
|
+
_ref = this.modelsArray;
|
253
|
+
_results = [];
|
254
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
255
|
+
model = _ref[_i];
|
256
|
+
_results.push(model.setReferencedModels(this.models));
|
257
|
+
}
|
258
|
+
return _results;
|
259
|
+
}
|
260
|
+
};
|
261
|
+
|
262
|
+
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
263
|
+
var consumes, o, op, _i, _len, _results;
|
264
|
+
if (ops) {
|
265
|
+
_results = [];
|
266
|
+
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
267
|
+
o = ops[_i];
|
268
|
+
consumes = o.consumes;
|
269
|
+
if (o.supportedContentTypes) {
|
270
|
+
consumes = o.supportedContentTypes;
|
271
|
+
}
|
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);
|
273
|
+
this.operations[op.nickname] = op;
|
274
|
+
_results.push(this.operationsArray.push(op));
|
275
|
+
}
|
276
|
+
return _results;
|
277
|
+
}
|
278
|
+
};
|
279
|
+
|
280
|
+
SwaggerResource.prototype.help = function() {
|
281
|
+
var operation, operation_name, parameter, _i, _len, _ref, _ref1;
|
282
|
+
_ref = this.operations;
|
283
|
+
for (operation_name in _ref) {
|
284
|
+
operation = _ref[operation_name];
|
285
|
+
console.log(" " + operation.nickname);
|
286
|
+
_ref1 = operation.parameters;
|
287
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
288
|
+
parameter = _ref1[_i];
|
289
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
290
|
+
}
|
291
|
+
}
|
292
|
+
return this;
|
293
|
+
};
|
294
|
+
|
295
|
+
return SwaggerResource;
|
296
|
+
|
297
|
+
})();
|
298
|
+
|
299
|
+
SwaggerModel = (function() {
|
300
|
+
|
301
|
+
function SwaggerModel(modelName, obj) {
|
302
|
+
var propertyName;
|
303
|
+
this.name = obj.id != null ? obj.id : modelName;
|
304
|
+
this.properties = [];
|
305
|
+
for (propertyName in obj.properties) {
|
306
|
+
this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName]));
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
310
|
+
SwaggerModel.prototype.setReferencedModels = function(allModels) {
|
311
|
+
var prop, _i, _len, _ref, _results;
|
312
|
+
_ref = this.properties;
|
313
|
+
_results = [];
|
314
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
315
|
+
prop = _ref[_i];
|
316
|
+
if (allModels[prop.dataType] != null) {
|
317
|
+
_results.push(prop.refModel = allModels[prop.dataType]);
|
318
|
+
} else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) {
|
319
|
+
_results.push(prop.refModel = allModels[prop.refDataType]);
|
320
|
+
} else {
|
321
|
+
_results.push(void 0);
|
322
|
+
}
|
323
|
+
}
|
324
|
+
return _results;
|
325
|
+
};
|
326
|
+
|
327
|
+
SwaggerModel.prototype.getMockSignature = function(prefix, modelsToIgnore) {
|
328
|
+
var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
|
329
|
+
propertiesStr = [];
|
330
|
+
_ref = this.properties;
|
331
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
332
|
+
prop = _ref[_i];
|
333
|
+
propertiesStr.push(prop.toString());
|
334
|
+
}
|
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">';
|
337
|
+
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
|
+
}
|
344
|
+
if (!modelsToIgnore) {
|
345
|
+
modelsToIgnore = [];
|
346
|
+
}
|
347
|
+
modelsToIgnore.push(this);
|
348
|
+
_ref1 = this.properties;
|
349
|
+
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
350
|
+
prop = _ref1[_j];
|
351
|
+
if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
|
352
|
+
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(void 0, modelsToIgnore));
|
353
|
+
}
|
354
|
+
}
|
355
|
+
return returnVal;
|
356
|
+
};
|
357
|
+
|
358
|
+
SwaggerModel.prototype.createJSONSample = function(modelToIgnore) {
|
359
|
+
var prop, result, _i, _len, _ref;
|
360
|
+
result = {};
|
361
|
+
_ref = this.properties;
|
362
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
363
|
+
prop = _ref[_i];
|
364
|
+
result[prop.name] = prop.getSampleValue(modelToIgnore);
|
365
|
+
}
|
366
|
+
return result;
|
367
|
+
};
|
368
|
+
|
369
|
+
return SwaggerModel;
|
370
|
+
|
371
|
+
})();
|
372
|
+
|
373
|
+
SwaggerModelProperty = (function() {
|
374
|
+
|
375
|
+
function SwaggerModelProperty(name, obj) {
|
376
|
+
this.name = name;
|
377
|
+
this.dataType = obj.type;
|
378
|
+
this.isArray = this.dataType.toLowerCase() === 'array';
|
379
|
+
this.descr = obj.description;
|
380
|
+
if (obj.items != null) {
|
381
|
+
if (obj.items.type != null) {
|
382
|
+
this.refDataType = obj.items.type;
|
383
|
+
}
|
384
|
+
if (obj.items.$ref != null) {
|
385
|
+
this.refDataType = obj.items.$ref;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
this.dataTypeWithRef = this.refDataType != null ? this.dataType + '[' + this.refDataType + ']' : this.dataType;
|
389
|
+
if (obj.allowableValues != null) {
|
390
|
+
this.valueType = obj.allowableValues.valueType;
|
391
|
+
this.values = obj.allowableValues.values;
|
392
|
+
if (this.values != null) {
|
393
|
+
this.valuesString = "'" + this.values.join("' or '") + "'";
|
394
|
+
}
|
395
|
+
}
|
396
|
+
}
|
397
|
+
|
398
|
+
SwaggerModelProperty.prototype.getSampleValue = function(modelToIgnore) {
|
399
|
+
var result;
|
400
|
+
if ((this.refModel != null) && (!(this.refModel === modelToIgnore))) {
|
401
|
+
result = this.refModel.createJSONSample(this.refModel);
|
402
|
+
} else {
|
403
|
+
if (this.isArray) {
|
404
|
+
result = this.refDataType;
|
405
|
+
} else {
|
406
|
+
result = this.dataType;
|
407
|
+
}
|
408
|
+
}
|
409
|
+
if (this.isArray) {
|
410
|
+
return [result];
|
411
|
+
} else {
|
412
|
+
return result;
|
413
|
+
}
|
414
|
+
};
|
415
|
+
|
416
|
+
SwaggerModelProperty.prototype.toString = function() {
|
417
|
+
var str;
|
418
|
+
str = this.name + ': ' + this.dataTypeWithRef;
|
419
|
+
if (this.values != null) {
|
420
|
+
str += " = ['" + this.values.join("' or '") + "']";
|
421
|
+
}
|
422
|
+
if (this.descr != null) {
|
423
|
+
str += ' {' + this.descr + '}';
|
424
|
+
}
|
425
|
+
return str;
|
426
|
+
};
|
427
|
+
|
428
|
+
return SwaggerModelProperty;
|
429
|
+
|
430
|
+
})();
|
431
|
+
|
432
|
+
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,
|
436
|
+
_this = this;
|
437
|
+
this.nickname = nickname;
|
438
|
+
this.path = path;
|
439
|
+
this.httpMethod = httpMethod;
|
440
|
+
this.parameters = parameters != null ? parameters : [];
|
441
|
+
this.summary = summary;
|
442
|
+
this.notes = notes;
|
443
|
+
this.responseClass = responseClass;
|
444
|
+
this.errorResponses = errorResponses;
|
445
|
+
this.resource = resource;
|
446
|
+
this.consumes = consumes;
|
447
|
+
this.produces = produces;
|
448
|
+
this["do"] = __bind(this["do"], this);
|
449
|
+
|
450
|
+
if (this.nickname == null) {
|
451
|
+
this.resource.api.fail("SwaggerOperations must have a nickname.");
|
452
|
+
}
|
453
|
+
if (this.path == null) {
|
454
|
+
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
|
455
|
+
}
|
456
|
+
if (this.httpMethod == null) {
|
457
|
+
this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
|
458
|
+
}
|
459
|
+
this.path = this.path.replace('{format}', 'json');
|
460
|
+
this.httpMethod = this.httpMethod.toLowerCase();
|
461
|
+
this.isGetMethod = this.httpMethod === "get";
|
462
|
+
this.resourceName = this.resource.name;
|
463
|
+
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
464
|
+
this.responseClass = void 0;
|
465
|
+
}
|
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);
|
469
|
+
}
|
470
|
+
this.errorResponses = this.errorResponses || [];
|
471
|
+
_ref1 = this.parameters;
|
472
|
+
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
473
|
+
parameter = _ref1[_i];
|
474
|
+
parameter.name = parameter.name || parameter.dataType;
|
475
|
+
if (parameter.dataType.toLowerCase() === 'boolean') {
|
476
|
+
parameter.allowableValues = {};
|
477
|
+
parameter.allowableValues.values = this.resource.api.booleanValues;
|
478
|
+
}
|
479
|
+
parameter.signature = this.getSignature(parameter.dataType, this.resource.models);
|
480
|
+
parameter.sampleJSON = this.getSampleJSON(parameter.dataType, this.resource.models);
|
481
|
+
if (parameter.allowableValues != null) {
|
482
|
+
if (parameter.allowableValues.valueType === "RANGE") {
|
483
|
+
parameter.isRange = true;
|
484
|
+
} else {
|
485
|
+
parameter.isList = true;
|
486
|
+
}
|
487
|
+
if (parameter.allowableValues.values != null) {
|
488
|
+
parameter.allowableValues.descriptiveValues = [];
|
489
|
+
_ref2 = parameter.allowableValues.values;
|
490
|
+
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
|
491
|
+
v = _ref2[_j];
|
492
|
+
if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
|
493
|
+
parameter.allowableValues.descriptiveValues.push({
|
494
|
+
value: v,
|
495
|
+
isDefault: true
|
496
|
+
});
|
497
|
+
} else {
|
498
|
+
parameter.allowableValues.descriptiveValues.push({
|
499
|
+
value: v,
|
500
|
+
isDefault: false
|
501
|
+
});
|
502
|
+
}
|
503
|
+
}
|
504
|
+
}
|
505
|
+
}
|
506
|
+
}
|
507
|
+
this.resource[this.nickname] = function(args, callback, error) {
|
508
|
+
return _this["do"](args, callback, error);
|
509
|
+
};
|
510
|
+
}
|
511
|
+
|
512
|
+
SwaggerOperation.prototype.isListType = function(dataType) {
|
513
|
+
if (dataType.indexOf('[') >= 0) {
|
514
|
+
return dataType.substring(dataType.indexOf('[') + 1, dataType.indexOf(']'));
|
515
|
+
} else {
|
516
|
+
return void 0;
|
517
|
+
}
|
518
|
+
};
|
519
|
+
|
520
|
+
SwaggerOperation.prototype.getSignature = function(dataType, models) {
|
521
|
+
var isPrimitive, listType;
|
522
|
+
listType = this.isListType(dataType);
|
523
|
+
isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true;
|
524
|
+
if (isPrimitive) {
|
525
|
+
return dataType;
|
526
|
+
} else {
|
527
|
+
if (listType != null) {
|
528
|
+
return models[listType].getMockSignature(dataType);
|
529
|
+
} else {
|
530
|
+
return models[dataType].getMockSignature(dataType);
|
531
|
+
}
|
532
|
+
}
|
533
|
+
};
|
534
|
+
|
535
|
+
SwaggerOperation.prototype.getSampleJSON = function(dataType, models) {
|
536
|
+
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());
|
540
|
+
if (val) {
|
541
|
+
val = listType ? [val] : val;
|
542
|
+
return JSON.stringify(val, null, 2);
|
543
|
+
}
|
544
|
+
};
|
545
|
+
|
546
|
+
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
547
|
+
var body, headers;
|
548
|
+
if (args == null) {
|
549
|
+
args = {};
|
550
|
+
}
|
551
|
+
if ((typeof args) === "function") {
|
552
|
+
error = callback;
|
553
|
+
callback = args;
|
554
|
+
args = {};
|
555
|
+
}
|
556
|
+
if (error == null) {
|
557
|
+
error = function(xhr, textStatus, error) {
|
558
|
+
return console.log(xhr, textStatus, error);
|
559
|
+
};
|
560
|
+
}
|
561
|
+
if (callback == null) {
|
562
|
+
callback = function(data) {
|
563
|
+
return console.log(data);
|
564
|
+
};
|
565
|
+
}
|
566
|
+
if (args.headers != null) {
|
567
|
+
headers = args.headers;
|
568
|
+
delete args.headers;
|
569
|
+
}
|
570
|
+
if (args.body != null) {
|
571
|
+
body = args.body;
|
572
|
+
delete args.body;
|
573
|
+
}
|
574
|
+
return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
|
575
|
+
};
|
576
|
+
|
577
|
+
SwaggerOperation.prototype.pathJson = function() {
|
578
|
+
return this.path.replace("{format}", "json");
|
579
|
+
};
|
580
|
+
|
581
|
+
SwaggerOperation.prototype.pathXml = function() {
|
582
|
+
return this.path.replace("{format}", "xml");
|
583
|
+
};
|
584
|
+
|
585
|
+
SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
|
586
|
+
var param, queryParams, reg, url, _i, _len, _ref;
|
587
|
+
if (includeApiKey == null) {
|
588
|
+
includeApiKey = true;
|
589
|
+
}
|
590
|
+
url = this.resource.basePath + this.pathJson();
|
591
|
+
_ref = this.parameters;
|
592
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
593
|
+
param = _ref[_i];
|
594
|
+
if (param.paramType === 'path') {
|
595
|
+
if (args[param.name]) {
|
596
|
+
reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
597
|
+
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
598
|
+
delete args[param.name];
|
599
|
+
} else {
|
600
|
+
throw "" + param.name + " is a required path param.";
|
601
|
+
}
|
602
|
+
}
|
603
|
+
}
|
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));
|
611
|
+
}
|
612
|
+
if ((queryParams != null) && queryParams.length > 0) {
|
613
|
+
url += "?" + queryParams;
|
614
|
+
}
|
615
|
+
return url;
|
616
|
+
};
|
617
|
+
|
618
|
+
SwaggerOperation.prototype.supportHeaderParams = function() {
|
619
|
+
return this.resource.api.supportHeaderParams;
|
620
|
+
};
|
621
|
+
|
622
|
+
SwaggerOperation.prototype.supportedSubmitMethods = function() {
|
623
|
+
return this.resource.api.supportedSubmitMethods;
|
624
|
+
};
|
625
|
+
|
626
|
+
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
|
627
|
+
if (includeApiKey == null) {
|
628
|
+
includeApiKey = true;
|
629
|
+
}
|
630
|
+
return this.getMatchingParams(['query', 'header'], args, includeApiKey);
|
631
|
+
};
|
632
|
+
|
633
|
+
SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
|
634
|
+
if (includeApiKey == null) {
|
635
|
+
includeApiKey = true;
|
636
|
+
}
|
637
|
+
return this.getMatchingParams(['query'], args, includeApiKey);
|
638
|
+
};
|
639
|
+
|
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) {
|
648
|
+
var matchingParams, name, param, value, _i, _len, _ref, _ref1;
|
649
|
+
matchingParams = {};
|
650
|
+
_ref = this.parameters;
|
651
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
652
|
+
param = _ref[_i];
|
653
|
+
if ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) {
|
654
|
+
matchingParams[param.name] = args[param.name];
|
655
|
+
}
|
656
|
+
}
|
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
|
+
}
|
666
|
+
}
|
667
|
+
return matchingParams;
|
668
|
+
};
|
669
|
+
|
670
|
+
SwaggerOperation.prototype.help = function() {
|
671
|
+
var parameter, _i, _len, _ref;
|
672
|
+
_ref = this.parameters;
|
673
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
674
|
+
parameter = _ref[_i];
|
675
|
+
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
676
|
+
}
|
677
|
+
return this;
|
678
|
+
};
|
679
|
+
|
680
|
+
return SwaggerOperation;
|
681
|
+
|
682
|
+
})();
|
683
|
+
|
684
|
+
SwaggerRequest = (function() {
|
685
|
+
|
686
|
+
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
687
|
+
var obj,
|
688
|
+
_this = this;
|
689
|
+
this.type = type;
|
690
|
+
this.url = url;
|
691
|
+
this.headers = headers;
|
692
|
+
this.body = body;
|
693
|
+
this.successCallback = successCallback;
|
694
|
+
this.errorCallback = errorCallback;
|
695
|
+
this.operation = operation;
|
696
|
+
if (this.type == null) {
|
697
|
+
throw "SwaggerRequest type is required (get/post/put/delete).";
|
698
|
+
}
|
699
|
+
if (this.url == null) {
|
700
|
+
throw "SwaggerRequest url is required.";
|
701
|
+
}
|
702
|
+
if (this.successCallback == null) {
|
703
|
+
throw "SwaggerRequest successCallback is required.";
|
704
|
+
}
|
705
|
+
if (this.errorCallback == null) {
|
706
|
+
throw "SwaggerRequest error callback is required.";
|
707
|
+
}
|
708
|
+
if (this.operation == null) {
|
709
|
+
throw "SwaggerRequest operation is required.";
|
710
|
+
}
|
711
|
+
if (this.operation.resource.api.verbose) {
|
712
|
+
console.log(this.asCurl());
|
713
|
+
}
|
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;
|
717
|
+
}
|
718
|
+
if (this.headers.mock == null) {
|
719
|
+
obj = {
|
720
|
+
type: this.type,
|
721
|
+
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);
|
729
|
+
}
|
730
|
+
};
|
731
|
+
if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
|
732
|
+
obj.contentType = "application/json";
|
733
|
+
}
|
734
|
+
jQuery.ajax(obj);
|
735
|
+
}
|
736
|
+
}
|
737
|
+
|
738
|
+
SwaggerRequest.prototype.asCurl = function() {
|
739
|
+
var header_args, k, v;
|
740
|
+
header_args = (function() {
|
741
|
+
var _ref, _results;
|
742
|
+
_ref = this.headers;
|
743
|
+
_results = [];
|
744
|
+
for (k in _ref) {
|
745
|
+
v = _ref[k];
|
746
|
+
_results.push("--header \"" + k + ": " + v + "\"");
|
747
|
+
}
|
748
|
+
return _results;
|
749
|
+
}).call(this);
|
750
|
+
return "curl " + (header_args.join(" ")) + " " + this.url;
|
751
|
+
};
|
752
|
+
|
753
|
+
return SwaggerRequest;
|
754
|
+
|
755
|
+
})();
|
756
|
+
|
757
|
+
window.SwaggerApi = SwaggerApi;
|
758
|
+
|
759
|
+
window.SwaggerResource = SwaggerResource;
|
760
|
+
|
761
|
+
window.SwaggerOperation = SwaggerOperation;
|
762
|
+
|
763
|
+
window.SwaggerRequest = SwaggerRequest;
|
764
|
+
|
765
|
+
}).call(this);
|