0&&(i.body=s.value);m=n.find("select");for(l=0,p=m.length;l0&&(i[s.name]=u);return o.responseContentType=$("div select[name=responseContentType]",$(this.el)).val(),o.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val(),$(".response_throbber",$(this.el)).show(),r?this.handleFileUpload(i,n):this.model["do"](i,o,this.showCompleteStatus,this.showErrorStatus,this)}},t.prototype.success=function(e,t){return t.showCompleteStatus(e)},t.prototype.handleFileUpload=function(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w=this;log("it's a file upload"),m=t.serializeArray();for(a=0,h=m.length;a0&&(e[s.name]=s.value);n=new FormData,g=this.model.parameters;for(f=0,p=g.length;f"+this.invocationUrl+""),o={type:this.model.method,url:this.invocationUrl,headers:i,data:n,dataType:"json",contentType:!1,processData:!1,error:function(e,t,n){return w.showErrorStatus(w.wrap(e),w)},success:function(e){return w.showResponse(e,w)},complete:function(e){return w.showCompleteStatus(w.wrap(e),w)}},window.authorizations&&window.authorizations.apply(o),jQuery.ajax(o),!1},t.prototype.wrap=function(e){var t,n,r,i,s,o,u;r={},n=e.getAllResponseHeaders().split("\r");for(o=0,u=n.length;o0?n.join(","):null},t.prototype.hideResponse=function(e){return e!=null&&e.preventDefault(),$(".response",$(this.el)).slideUp(),$(".response_hider",$(this.el)).fadeOut()},t.prototype.showResponse=function(e){var t;return t=JSON.stringify(e,null," ").replace(/\n/g,"
"),$(".response_body",$(this.el)).html(escape(t))},t.prototype.showErrorStatus=function(e,t){return t.showStatus(e)},t.prototype.showCompleteStatus=function(e,t){return t.showStatus(e)},t.prototype.formatXml=function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p;a=/(>)(<)(\/*)/g,l=/[ ]*(.*)[ ]+\n/g,t=/(<.+>)(.+\n)/g,e=e.replace(a,"$1\n$2$3").replace(l,"$1\n").replace(t,"$1\n$2"),u=0,n="",s=e.split("\n"),r=0,i="other",f={"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},c=function(e){var t,s,o,u,a,l,c;return l={single:Boolean(e.match(/<.+\/>/)),closing:Boolean(e.match(/<\/.+>/)),opening:Boolean(e.match(/<[^!?].*>/))},a=function(){var e;e=[];for(o in l)c=l[o],c&&e.push(o);return e}()[0],a=a===void 0?"other":a,t=i+"->"+a,i=a,u="",r+=f[t],u=function(){var e,t,n;n=[];for(s=e=0,t=r;0<=t?et;s=0<=t?++e:--e)n.push(" ");return n}().join(""),t==="opening->closing"?n=n.substr(0,n.length-1)+e+"\n":n+=u+e+"\n"};for(h=0,p=s.length;h").text(JSON.stringify(JSON.parse(n),null," ")),s=$('').append(t)):r==="application/xml"||/\+xml$/.test(r)?(t=$("
").text(this.formatXml(n)),s=$('').append(t)):r==="text/html"?(t=$("
").html(n),s=$('').append(t)):/^image\//.test(r)?s=$("
").attr("src",u):(t=$("
").text(n),s=$('').append(t)):(t=$("
").text("no content"),s=$('').append(t)),o=s,$(".request_url",$(this.el)).html(""+u+"
"),$(".response_code",$(this.el)).html(""+e.status+" "+e.statusText+"
"),$(".response_body",$(this.el)).html(o),$(".response_headers",$(this.el)).html(""+JSON.stringify(e.headers,null," ").replace(/\n/g,"
")+"
"),$(".response",$(this.el)).slideDown(),$(".response_hider",$(this.el)).show(),$(".response_throbber",$(this.el)).hide(),hljs.highlightBlock($(".response_body",$(this.el))[0])},t.prototype.toggleOperationContent=function(){var e;return e=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content"),e.is(":visible")?Docs.collapseOperation(e):Docs.expandOperation(e)},t}(Backbone.View),f=function(e){function t(){return g=t.__super__.constructor.apply(this,arguments),g}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this},t.prototype.template=function(){return Handlebars.templates.status_code},t}(Backbone.View),s=function(e){function t(){return y=t.__super__.constructor.apply(this,arguments),y}return x(t,e),t.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(e,t){return e.type.toLowerCase()==="array"||e.allowMultiple?t.fn(this):t.inverse(this)})},t.prototype.render=function(){var e,t,n,r,s,o,f,l;return l=this.model.type||this.model.dataType,this.model.paramType==="body"&&(this.model.isBody=!0),l.toLowerCase()==="file"&&(this.model.isFile=!0),f=this.template(),$(this.el).html(f(this.model)),s={sampleJSON:this.model.sampleJSON,isParam:!0,signature:this.model.signature},this.model.sampleJSON?(o=new a({model:s,tagName:"div"}),$(".model-signature",$(this.el)).append(o.render().el)):$(".model-signature",$(this.el)).html(this.model.signature),t=!1,this.model.isBody&&(t=!0),e={isParam:t},e.consumes=this.model.consumes,t?(n=new i({model:e}),$(".parameter-content-type",$(this.el)).append(n.render().el)):(r=new u({model:e}),$(".response-content-type",$(this.el)).append(r.render().el)),this},t.prototype.template=function(){return this.model.isList?Handlebars.templates.param_list:this.options.readOnly?this.model.required?Handlebars.templates.param_readonly_required:Handlebars.templates.param_readonly:this.model.required?Handlebars.templates.param_required:Handlebars.templates.param},t}(Backbone.View),a=function(e){function t(){return b=t.__super__.constructor.apply(this,arguments),b}return x(t,e),t.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"},t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this.switchToDescription(),this.isParam=this.model.isParam,this.isParam&&$(".notice",$(this.el)).text("Click to set as parameter value"),this},t.prototype.template=function(){return Handlebars.templates.signature},t.prototype.switchToDescription=function(e){return e!=null&&e.preventDefault(),$(".snippet",$(this.el)).hide(),$(".description",$(this.el)).show(),$(".description-link",$(this.el)).addClass("selected"),$(".snippet-link",$(this.el)).removeClass("selected")},t.prototype.switchToSnippet=function(e){return e!=null&&e.preventDefault(),$(".description",$(this.el)).hide(),$(".snippet",$(this.el)).show(),$(".snippet-link",$(this.el)).addClass("selected"),$(".description-link",$(this.el)).removeClass("selected")},t.prototype.snippetToTextArea=function(e){var t;if(this.isParam){e!=null&&e.preventDefault(),t=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(t.val())==="")return t.val(this.model.sampleJSON)}},t}(Backbone.View),e=function(e){function t(){return w=t.__super__.constructor.apply(this,arguments),w}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=contentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.content_type},t}(Backbone.View),u=function(e){function t(){return E=t.__super__.constructor.apply(this,arguments),E}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=responseContentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.response_content_type},t}(Backbone.View),i=function(e){function t(){return p=t.__super__.constructor.apply(this,arguments),p}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:"),this},t.prototype.template=function(){return Handlebars.templates.parameter_content_type},t}(Backbone.View)}.call(this);
\ No newline at end of file
+function clippyCopiedCallback(e){$("#api_key_copied").fadeIn().delay(1e3).fadeOut()}$(function(){$.fn.vAlign=function(){return this.each(function(e){var t=$(this).height(),n=$(this).parent().height(),a=(n-t)/2;$(this).css("margin-top",a)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(e){var t=$(this).closest("form").innerWidth(),n=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",t-n-a)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),""==$(this).val()&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),log=function(){log.history=log.history||[],log.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments))},Function.prototype.bind&&console&&"object"==typeof console.log&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var Docs={shebang:function(){var e=$.param.fragment().split("/");switch(e.shift(),e.length){case 1:log("shebang resource:"+e[0]);var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});break;case 2:log("shebang endpoint: "+e.join("_")),Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),a=n+"_content";log("li_dom_id "+n),log("li_content_dom_id "+a),Docs.expandOperation($("#"+a)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?Docs.collapseEndpointListForResource(e):Docs.expandEndpointListForResource(e)},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideDown();$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideDown():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){Docs.expandEndpointListForResource(e),$("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}};!function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.content_type=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n ",a=n.each.call(e,e.produces,{hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n"}function s(e,t){var n,a="";return a+='\n\t\n\t"}function i(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var l,p="",c="function",d=this;return p+='\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.main=e(function(e,t,n,a,r){function o(e,t){var a,r,o="";return o+='\n '+h((a=e.info,a=null==a||a===!1?a:a.title,typeof a===u?a.apply(e):a))+'
\n ',a=e.info,a=null==a||a===!1?a:a.description,r=typeof a===u?a.apply(e):a,(r||0===r)&&(o+=r),o+="
\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.termsOfServiceUrl),{hash:{},inverse:m.noop,fn:m.program(2,s,t),data:t}),(r||0===r)&&(o+=r),o+="\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.contact),{hash:{},inverse:m.noop,fn:m.program(4,i,t),data:t}),(r||0===r)&&(o+=r),o+="\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.license),{hash:{},inverse:m.noop,fn:m.program(6,l,t),data:t}),(r||0===r)&&(o+=r),o+="\n "}function s(e,t){var n,a="";return a+=''}function i(e,t){var n,a="";return a+="'}function l(e,t){var n,a="";return a+=""}function p(e,t){var a,r="";return r+='\n , api version: ',(a=n.apiVersion)?a=a.call(e,{hash:{},data:t}):(a=e.apiVersion,a=typeof a===u?a.apply(e):a),r+=h(a)+"\n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var c,d="",u="function",h=this.escapeExpression,m=this;return d+="\n ",c=n.if.call(t,t.info,{hash:{},inverse:m.noop,fn:m.program(1,o,r),data:r}),(c||0===c)&&(d+=c),d+="\n
\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.operation=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n Implementation Notes
\n ",(a=n.notes)?a=a.call(e,{hash:{},data:t}):(a=e.notes,a=typeof a===$?a.apply(e):a),(a||0===a)&&(r+=a),r+="
\n "}function s(e,t){return'\n \n
'}function i(e,t){var a,r="";return r+='\n
\n ',a=n.each.call(e,e,{hash:{},inverse:_.noop,fn:_.program(6,l,t),data:t}),(a||0===a)&&(r+=a),r+="\n
\n "}function l(e,t){var n,a,r="";return r+="\n
"+b((n=e.scope,typeof n===$?n.apply(e):n))+"
\n "}function p(e,t){return"
"}function c(e,t){return'\n \n \n
\n '}function d(e,t){return'\n Response Class
\n
\n
\n \n '}function u(e,t){return'\n Parameters
\n \n \n \n Parameter | \n Value | \n Description | \n Parameter Type | \n Data Type | \n
\n \n \n\n \n
\n '}function h(e,t){return"\n \n Error Status Codes
\n \n \n \n HTTP Status Code | \n Reason | \n
\n \n \n \n \n
\n "}function m(e,t){return"\n "}function f(e,t){return"\n \n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var y,g,v="",$="function",b=this.escapeExpression,_=this,w=n.blockHelperMissing;return v+="\n \n - \n \n
\n ",y=n.if.call(t,t.notes,{hash:{},inverse:_.noop,fn:_.program(1,o,r),data:r}),(y||0===y)&&(v+=y),v+="\n ",g={hash:{},inverse:_.noop,fn:_.program(3,s,r),data:r},(y=n.oauth)?y=y.call(t,g):(y=t.oauth,y=typeof y===$?y.apply(t):y),n.oauth||(y=w.call(t,y,g)),(y||0===y)&&(v+=y),v+="\n ",y=n.each.call(t,t.oauth,{hash:{},inverse:_.noop,fn:_.program(5,i,r),data:r}),(y||0===y)&&(v+=y),v+="\n ",g={hash:{},inverse:_.noop,fn:_.program(8,p,r),data:r},(y=n.oauth)?y=y.call(t,g):(y=t.oauth,y=typeof y===$?y.apply(t):y),n.oauth||(y=w.call(t,y,g)),(y||0===y)&&(v+=y),v+="\n ",g={hash:{},inverse:_.noop,fn:_.program(10,c,r),data:r},(y=n.oauth)?y=y.call(t,g):(y=t.oauth,y=typeof y===$?y.apply(t):y),n.oauth||(y=w.call(t,y,g)),(y||0===y)&&(v+=y),v+="\n ",y=n.if.call(t,t.type,{hash:{},inverse:_.noop,fn:_.program(12,d,r),data:r}),(y||0===y)&&(v+=y),v+="\n
\n
\n
Request URL
\n
\n
Response Body
\n
\n
Response Code
\n
\n
Response Headers
\n \n
\n
\n \n
\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.param=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n\t\t",a=n.if.call(e,e.isFile,{hash:{},inverse:g.program(4,i,t),fn:g.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t"}function s(e,t){var a,r="";return r+='\n\t\t\t\n\t\t\t\n\t\t'}function i(e,t){var a,r="";return r+="\n\t\t\t",a=n.if.call(e,e.defaultValue,{hash:{},inverse:g.program(7,p,t),fn:g.program(5,l,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t\t"}function l(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t"}function p(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\n\t\t\t'}function c(e,t){var a,r="";return r+="\n\t\t",a=n.if.call(e,e.defaultValue,{hash:{},inverse:g.program(12,u,t),fn:g.program(10,d,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t"}function d(e,t){var a,r="";return r+="\n\t\t\t\n\t\t"}function u(e,t){var a,r="";return r+="\n\t\t\t\n\t\t"}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var h,m="",f="function",y=this.escapeExpression,g=this;return m+="",(h=n.name)?h=h.call(t,{hash:{},data:r}):(h=t.name,h=typeof h===f?h.apply(t):h),m+=y(h)+" | \n\n\n\t",h=n.if.call(t,t.isBody,{hash:{},inverse:g.program(9,c,r),fn:g.program(1,o,r),data:r}),(h||0===h)&&(m+=h),m+="\n\n | \n",(h=n.description)?h=h.call(t,{hash:{},data:r}):(h=t.description,h=typeof h===f?h.apply(t):h),(h||0===h)&&(m+=h),m+=" | \n",(h=n.paramType)?h=h.call(t,{hash:{},data:r}):(h=t.paramType,h=typeof h===f?h.apply(t):h),(h||0===h)&&(m+=h),m+=' | \n\n\t\n | \n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.param_list=e(function(e,t,n,a,r){function o(e,t){return" multiple='multiple'"}function s(e,t){return"\n "}function i(e,t){var a,r="";return r+="\n ",a=n.if.call(e,e.defaultValue,{hash:{},inverse:$.program(8,p,t),fn:$.program(6,l,t),data:t}),(a||0===a)&&(r+=a),r+="\n "}function l(e,t){return"\n "}function p(e,t){var a,r,o,s="";return s+="\n ",o={hash:{},inverse:$.program(11,d,t),fn:$.program(9,c,t),data:t},a=n.isArray||e.isArray,r=a?a.call(e,e,o):b.call(e,"isArray",e,o),(r||0===r)&&(s+=r),s+="\n "}function c(e,t){return"\n "}function d(e,t){return"\n \n "}function u(e,t){var a,r="";return r+="\n ",a=n.if.call(e,e.isDefault,{hash:{},inverse:$.program(16,m,t),fn:$.program(14,h,t),data:t}),(a||0===a)&&(r+=a),r+="\n "}function h(e,t){var a,r="";return r+='\n \n "}function m(e,t){var a,r="";return r+="\n \n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var f,y,g,v="",$=this,b=n.helperMissing,_="function",w=this.escapeExpression;return v+="",(f=n.name)?f=f.call(t,{hash:{},data:r}):(f=t.name,f=typeof f===_?f.apply(t):f),v+=w(f)+" | \n\n \n | \n",(y=n.description)?y=y.call(t,{hash:{},data:r}):(y=t.description,y=typeof y===_?y.apply(t):y),(y||0===y)&&(v+=y),v+=" | \n",(y=n.paramType)?y=y.call(t,{hash:{},data:r}):(y=t.paramType,y=typeof y===_?y.apply(t):y),(y||0===y)&&(v+=y),v+=' | \n | '})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.param_readonly=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n \n "}function s(e,t){var a,r="";return r+="\n ",a=n.if.call(e,e.defaultValue,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,i,t),data:t}),(a||0===a)&&(r+=a),r+="\n "}function i(e,t){var a,r="";return r+="\n ",(a=n.defaultValue)?a=a.call(e,{hash:{},data:t}):(a=e.defaultValue,a=typeof a===d?a.apply(e):a),r+=u(a)+"\n "}function l(e,t){return"\n (empty)\n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var p,c="",d="function",u=this.escapeExpression,h=this;return c+="",(p=n.name)?p=p.call(t,{hash:{},data:r}):(p=t.name,p=typeof p===d?p.apply(t):p),c+=u(p)+" | \n\n ",p=n.if.call(t,t.isBody,{hash:{},inverse:h.program(3,s,r),fn:h.program(1,o,r),data:r}),(p||0===p)&&(c+=p),c+="\n | \n",(p=n.description)?p=p.call(t,{hash:{},data:r}):(p=t.description,p=typeof p===d?p.apply(t):p),(p||0===p)&&(c+=p),c+=" | \n",(p=n.paramType)?p=p.call(t,{hash:{},data:r}):(p=t.paramType,p=typeof p===d?p.apply(t):p),(p||0===p)&&(c+=p),c+=' | \n | \n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.param_readonly_required=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n \n "}function s(e,t){var a,r="";return r+="\n ",a=n.if.call(e,e.defaultValue,{hash:{},inverse:h.program(6,l,t),fn:h.program(4,i,t),data:t}),(a||0===a)&&(r+=a),r+="\n "}function i(e,t){var a,r="";return r+="\n ",(a=n.defaultValue)?a=a.call(e,{hash:{},data:t}):(a=e.defaultValue,a=typeof a===d?a.apply(e):a),r+=u(a)+"\n "}function l(e,t){return"\n (empty)\n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var p,c="",d="function",u=this.escapeExpression,h=this;return c+="",(p=n.name)?p=p.call(t,{hash:{},data:r}):(p=t.name,p=typeof p===d?p.apply(t):p),c+=u(p)+" | \n\n ",p=n.if.call(t,t.isBody,{hash:{},inverse:h.program(3,s,r),fn:h.program(1,o,r),data:r}),(p||0===p)&&(c+=p),c+="\n | \n",(p=n.description)?p=p.call(t,{hash:{},data:r}):(p=t.description,p=typeof p===d?p.apply(t):p),(p||0===p)&&(c+=p),c+=" | \n",(p=n.paramType)?p=p.call(t,{hash:{},data:r}):(p=t.paramType,p=typeof p===d?p.apply(t):p),(p||0===p)&&(c+=p),c+=' | \n | \n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.param_required=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n\t\t",a=n.if.call(e,e.isFile,{hash:{},inverse:$.program(4,i,t),fn:$.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t"}function s(e,t){var a,r="";return r+='\n\t\t\t\n\t\t"}function i(e,t){var a,r="";return r+="\n\t\t\t",a=n.if.call(e,e.defaultValue,{hash:{},inverse:$.program(7,p,t),fn:$.program(5,l,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t\t"}function l(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t"}function p(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t\t
\n\t\t\t\t\n\t\t\t'}function c(e,t){var a,r="";return r+="\n\t\t",a=n.if.call(e,e.isFile,{hash:{},inverse:$.program(12,u,t),fn:$.program(10,d,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t"}function d(e,t){var a,r="";return r+="\n\t\t\t\n\t\t"}function u(e,t){var a,r="";return r+="\n\t\t\t",a=n.if.call(e,e.defaultValue,{hash:{},inverse:$.program(15,m,t),fn:$.program(13,h,t),data:t}),(a||0===a)&&(r+=a),r+="\n\t\t"}function h(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t"}function m(e,t){var a,r="";return r+="\n\t\t\t\t\n\t\t\t"}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var f,y="",g="function",v=this.escapeExpression,$=this;return y+="",(f=n.name)?f=f.call(t,{hash:{},data:r}):(f=t.name,f=typeof f===g?f.apply(t):f),y+=v(f)+" | \n\n\t",f=n.if.call(t,t.isBody,{hash:{},inverse:$.program(9,c,r),fn:$.program(1,o,r),data:r}),(f||0===f)&&(y+=f),y+="\n | \n\n\t",(f=n.description)?f=f.call(t,{hash:{},data:r}):(f=t.description,f=typeof f===g?f.apply(t):f),(f||0===f)&&(y+=f),y+="\n | \n",(f=n.paramType)?f=f.call(t,{hash:{},data:r}):(f=t.paramType,f=typeof f===g?f.apply(t):f),(f||0===f)&&(y+=f),y+=' | \n | \n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.parameter_content_type=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n ",a=n.each.call(e,e.consumes,{hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n"}function s(e,t){var n,a="";return a+='\n \n "}function i(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var l,p="",c="function",d=this;return p+='\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.resource=e(function(e,t,n,a,r){function o(e,t){return" : "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var s,i,l="",p="function",c=this.escapeExpression,d=this,u=n.blockHelperMissing;return l+="\n
\n ",(s=n.name)?s=s.call(t,{hash:{},data:r}):(s=t.name,s=typeof s===p?s.apply(t):s),l+=c(s)+" ",i={hash:{},inverse:d.noop,fn:d.program(1,o,r),data:r},(s=n.description)?s=s.call(t,i):(s=t.description,s=typeof s===p?s.apply(t):s),n.description||(s=u.call(t,s,i)),(s||0===s)&&(l+=s),(s=n.description)?s=s.call(t,{hash:{},data:r}):(s=t.description,s=typeof s===p?s.apply(t):s),(s||0===s)&&(l+=s),l+="\n
\n
\n
\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.response_content_type=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n ",a=n.each.call(e,e.produces,{hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n"}function s(e,t){var n,a="";return a+='\n \n "}function i(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var l,p="",c="function",d=this;return p+='\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.signature=e(function(e,t,n,a,r){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var o,s="",i="function",l=this.escapeExpression;return s+='\n
\n
\n\n
\n
\n ',(o=n.signature)?o=o.call(t,{hash:{},data:r}):(o=t.signature,o=typeof o===i?o.apply(t):o),(o||0===o)&&(s+=o),s+='\n
\n\n
\n
',(o=n.sampleJSON)?o=o.call(t,{hash:{},data:r}):(o=t.sampleJSON,o=typeof o===i?o.apply(t):o),s+=l(o)+'
\n
\n
\n
\n\n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.status_code=e(function(e,t,n,a,r){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var o,s="",i="function",l=this.escapeExpression;return s+="
",(o=n.code)?o=o.call(t,{hash:{},data:r}):(o=t.code,o=typeof o===i?o.apply(t):o),s+=l(o)+" | \n
",(o=n.message)?o=o.call(t,{hash:{},data:r}):(o=t.message,o=typeof o===i?o.apply(t):o),(o||0===o)&&(s+=o),s+=" | \n"})}(),function(){var e,t,n,a,r,o,s,i,l,p,c,d,u,h,m,f,y,g,v,b,_,w,x={}.hasOwnProperty,k=function(e,t){function n(){this.constructor=e}for(var a in t)x.call(t,a)&&(e[a]=t[a]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};c=function(e){function a(){return d=a.__super__.constructor.apply(this,arguments)}return k(a,e),a.prototype.dom_id="swagger_ui",a.prototype.options=null,a.prototype.api=null,a.prototype.headerView=null,a.prototype.mainView=null,a.prototype.initialize=function(e){var n=this;return null==e&&(e={}),null!=e.dom_id&&(this.dom_id=e.dom_id,delete e.dom_id),null==$("#"+this.dom_id)&&$("body").append('
'),this.options=e,this.options.success=function(){return n.render()},this.options.progress=function(e){return n.showMessage(e)},this.options.failure=function(e){return n.onLoadFailure(e)},this.headerView=new t({el:$("#header")}),this.headerView.on("update-swagger-ui",function(e){return n.updateSwaggerUi(e)})},a.prototype.updateSwaggerUi=function(e){return this.options.url=e.url,this.load()},a.prototype.load=function(){var e,t;return null!=(t=this.mainView)&&t.clear(),e=this.options.url,0!==e.indexOf("http")&&(e=this.buildUrl(window.location.href.toString(),e)),this.options.url=e,this.headerView.update(e),this.api=new SwaggerApi(this.options),this.api.build(),this.api},a.prototype.render=function(){switch(this.showMessage("Finished Loading Resource Information. Rendering Swagger UI..."),this.mainView=new n({model:this.api,el:$("#"+this.dom_id)}).render(),this.showMessage(),this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}return this.options.onComplete&&this.options.onComplete(this.api,this),setTimeout(function(){return Docs.shebang()},400)},a.prototype.buildUrl=function(e,t){var n,a;return log("base is "+e),0===t.indexOf("/")?(a=e.split("/"),e=a[0]+"//"+a[2],e+t):(n=e.length,e.indexOf("?")>-1&&(n=Math.min(n,e.indexOf("?"))),e.indexOf("#")>-1&&(n=Math.min(n,e.indexOf("#"))),e=e.substring(0,n),e.indexOf("/",e.length-1)!==-1?e+t:e+"/"+t);
+},a.prototype.showMessage=function(e){return null==e&&(e=""),$("#message-bar").removeClass("message-fail"),$("#message-bar").addClass("message-success"),$("#message-bar").html(e)},a.prototype.onLoadFailure=function(e){var t;return null==e&&(e=""),$("#message-bar").removeClass("message-success"),$("#message-bar").addClass("message-fail"),t=$("#message-bar").html(e),null!=this.options.onFailure&&this.options.onFailure(e),t},a}(Backbone.Router),window.SwaggerUi=c,t=function(e){function t(){return u=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.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"},t.prototype.initialize=function(){},t.prototype.showPetStore=function(e){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})},t.prototype.showWordnikDev=function(e){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})},t.prototype.showCustomOnKeyup=function(e){if(13===e.keyCode)return this.showCustom()},t.prototype.showCustom=function(e){return null!=e&&e.preventDefault(),this.trigger("update-swagger-ui",{url:$("#input_baseUrl").text(),apiKey:$("#input_apiKey").text()})},t.prototype.update=function(e,t,n){if(null==n&&(n=!1),$("#input_baseUrl").val(e),n)return this.trigger("update-swagger-ui",{url:e})},t}(Backbone.View),n=function(e){function t(){return m=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e,t,n,a,r,o,s;for($(this.el).html(Handlebars.templates.main(this.model)),a={},e=0,s=this.model.apisArray,r=0,o=s.length;r
r&&(p=r-l),po&&(c=o-n),c0&&(r[o.name]=o.value),"file"===o.type&&(a=!0);for(f=n.find("textarea"),p=0,u=f.length;p0&&(r.body=o.value);for(y=n.find("select"),c=0,h=y.length;c0&&(r[o.name]=i);return s.responseContentType=$("div select[name=responseContentType]",$(this.el)).val(),s.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val(),$(".response_throbber",$(this.el)).show(),a?this.handleFileUpload(r,n):this.model.do(r,s,this.showCompleteStatus,this.showErrorStatus,this)}},t.prototype.success=function(e,t){return t.showCompleteStatus(e)},t.prototype.handleFileUpload=function(e,t){var n,a,r,o,s,i,l,p,c,d,u,h,m,f,y,g,v,b,_=this;for(log("it's a file upload"),y=t.serializeArray(),l=0,u=y.length;l0&&(e[o.name]=o.value);for(n=new FormData,g=this.model.parameters,p=0,h=g.length;p"+this.invocationUrl+""),s={type:this.model.method,url:this.invocationUrl,headers:r,data:n,dataType:"json",contentType:!1,processData:!1,error:function(e,t,n){return _.showErrorStatus(_.wrap(e),_)},success:function(e){return _.showResponse(e,_)},complete:function(e){return _.showCompleteStatus(_.wrap(e),_)}},window.authorizations&&window.authorizations.apply(s),jQuery.ajax(s),!1},t.prototype.wrap=function(e){var t,n,a,r,o,s,i;for(a={},n=e.getAllResponseHeaders().split("\r"),s=0,i=n.length;s0?n.join(","):null}return e.value},t.prototype.hideResponse=function(e){return null!=e&&e.preventDefault(),$(".response",$(this.el)).slideUp(),$(".response_hider",$(this.el)).fadeOut()},t.prototype.showResponse=function(e){var t;return t=JSON.stringify(e,null,"\t").replace(/\n/g,"
"),$(".response_body",$(this.el)).html(escape(t))},t.prototype.showErrorStatus=function(e,t){return t.showStatus(e)},t.prototype.showCompleteStatus=function(e,t){return t.showStatus(e)},t.prototype.formatXml=function(e){var t,n,a,r,o,s,i,l,p,c,d,u,h;for(l=/(>)(<)(\/*)/g,c=/[ ]*(.*)[ ]+\n/g,t=/(<.+>)(.+\n)/g,e=e.replace(l,"$1\n$2$3").replace(c,"$1\n").replace(t,"$1\n$2"),i=0,n="",o=e.split("\n"),a=0,r="other",p={"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},d=function(e){var t,o,s,i,l,c,d;return c={single:Boolean(e.match(/<.+\/>/)),closing:Boolean(e.match(/<\/.+>/)),opening:Boolean(e.match(/<[^!?].*>/))},l=function(){var e;e=[];for(s in c)d=c[s],d&&e.push(s);return e}()[0],l=void 0===l?"other":l,t=r+"->"+l,r=l,i="",a+=p[t],i=function(){var e,t,n;for(n=[],o=e=0,t=a;0<=t?et;o=0<=t?++e:--e)n.push(" ");return n}().join(""),"opening->closing"===t?n=n.substr(0,n.length-1)+e+"\n":n+=i+e+"\n"},u=0,h=o.length;u").text(JSON.stringify(JSON.parse(n),null," ")),o=$('').append(t)):"application/xml"===a||/\+xml$/.test(a)?(t=$("
").text(this.formatXml(n)),o=$('').append(t)):"text/html"===a?(t=$("
").html(n),o=$('').append(t)):/^image\//.test(a)?o=$("
").attr("src",i):(t=$("
").text(n),o=$('').append(t)):(t=$("
").text("no content"),o=$('').append(t)),s=o,$(".request_url",$(this.el)).html(""+i+"
"),$(".response_code",$(this.el)).html(""+e.status+" "+e.statusText+"
"),$(".response_body",$(this.el)).html(s),$(".response_headers",$(this.el)).html(""+JSON.stringify(e.headers,null," ").replace(/\n/g,"
")+"
"),$(".response",$(this.el)).slideDown(),$(".response_hider",$(this.el)).show(),$(".response_throbber",$(this.el)).hide(),hljs.highlightBlock($(".response_body",$(this.el))[0])},t.prototype.toggleOperationContent=function(){var e;return e=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content"),e.is(":visible")?Docs.collapseOperation(e):Docs.expandOperation(e)},t}(Backbone.View),p=function(e){function t(){return g=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this},t.prototype.template=function(){return Handlebars.templates.status_code},t}(Backbone.View),o=function(e){function t(){return v=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(e,t){return"array"===e.type.toLowerCase()||e.allowMultiple?t.fn(this):t.inverse(this)})},t.prototype.render=function(){var e,t,n,a,o,s,p,c;return c=this.model.type||this.model.dataType,"body"===this.model.paramType&&(this.model.isBody=!0),"file"===c.toLowerCase()&&(this.model.isFile=!0),p=this.template(),$(this.el).html(p(this.model)),o={sampleJSON:this.model.sampleJSON,isParam:!0,signature:this.model.signature},this.model.sampleJSON?(s=new l({model:o,tagName:"div"}),$(".model-signature",$(this.el)).append(s.render().el)):$(".model-signature",$(this.el)).html(this.model.signature),t=!1,this.model.isBody&&(t=!0),e={isParam:t},e.consumes=this.model.consumes,t?(n=new r({model:e}),$(".parameter-content-type",$(this.el)).append(n.render().el)):(a=new i({model:e}),$(".response-content-type",$(this.el)).append(a.render().el)),this},t.prototype.template=function(){return this.model.isList?Handlebars.templates.param_list:this.options.readOnly?this.model.required?Handlebars.templates.param_readonly_required:Handlebars.templates.param_readonly:this.model.required?Handlebars.templates.param_required:Handlebars.templates.param},t}(Backbone.View),l=function(e){function t(){return b=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"},t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this.switchToDescription(),this.isParam=this.model.isParam,this.isParam&&$(".notice",$(this.el)).text("Click to set as parameter value"),this},t.prototype.template=function(){return Handlebars.templates.signature},t.prototype.switchToDescription=function(e){return null!=e&&e.preventDefault(),$(".snippet",$(this.el)).hide(),$(".description",$(this.el)).show(),$(".description-link",$(this.el)).addClass("selected"),$(".snippet-link",$(this.el)).removeClass("selected")},t.prototype.switchToSnippet=function(e){return null!=e&&e.preventDefault(),$(".description",$(this.el)).hide(),$(".snippet",$(this.el)).show(),$(".snippet-link",$(this.el)).addClass("selected"),$(".description-link",$(this.el)).removeClass("selected")},t.prototype.snippetToTextArea=function(e){var t;if(this.isParam&&(null!=e&&e.preventDefault(),t=$("textarea",$(this.el.parentNode.parentNode.parentNode)),""===$.trim(t.val())))return t.val(this.model.sampleJSON)},t}(Backbone.View),e=function(e){function t(){return _=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=contentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.content_type},t}(Backbone.View),i=function(e){function t(){return w=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=responseContentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.response_content_type},t}(Backbone.View),r=function(e){function t(){return h=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:"),this},t.prototype.template=function(){return Handlebars.templates.parameter_content_type},t}(Backbone.View)}.call(this);
diff --git a/rest_framework_swagger/tests.py b/rest_framework_swagger/tests.py
index 875dfc55..d58bbe76 100644
--- a/rest_framework_swagger/tests.py
+++ b/rest_framework_swagger/tests.py
@@ -1,9 +1,6 @@
import datetime
-import platform
import functools
-import os
import copy
-import os.path
from mock import Mock, patch
from distutils.version import StrictVersion
try:
@@ -19,7 +16,11 @@
from django.test import TestCase
from django.test.utils import override_settings
from django.utils.decorators import classonlymethod
-from django.utils.importlib import import_module
+try:
+ from django.utils.module_loading import import_module
+except ImportError:
+ from django.utils.importlib import import_module
+
from django.views.generic import View
import django_filters
@@ -2775,187 +2776,3 @@ def wrapped(*view_args, **view_kwargs):
cls.as_view = classonlymethod(new_as_view)
return cls
return wrapper
-
-
-if platform.python_version_tuple()[:2] != ('3', '2'):
- class Swagger1_2Tests(TestCase):
- """
- build some swagger endpoints, and run swagger's JSON schema on the results.
- """
- def setUp(self):
- from json import loads
- self.schemas = {}
- schema_dir = 'schemas/v1.2'
- for schema_file in [x for x in os.listdir(schema_dir)
- if x.endswith('.json')]:
- with open(os.path.join(schema_dir, schema_file)) as f:
- schema = loads(f.read())
- self.schemas[schema_file] = schema
-
- def get_validator(self, schema_name):
- from jsonschema import Draft4Validator
- validator = Draft4Validator(self.schemas[schema_name + '.json'])
-
- def http_handler(uri):
- from django.utils.six.moves.urllib import parse
- urp = parse.urlparse(uri)
- paff = os.path.basename(urp.path)
- return self.schemas[paff]
- validator.resolver.handlers['http'] = http_handler
- return validator
-
- def test1(self):
- class MockApiView(APIView):
- def get_serializer_class(self):
- return KitchenSinkSerializer
-
- def get(self, request):
- pass
- self.url_patterns = patterns(
- '',
- url(r'^a-view/?$', MockApiView.as_view(), name='a test view'),
- url(r'^swagger/', include('rest_framework_swagger.urls')),
- )
- urls = import_module(settings.ROOT_URLCONF)
- urls.urlpatterns = self.url_patterns
-
- validator = self.get_validator("resourceListing")
- response = self.client.get("/swagger/api-docs/")
- json = parse_json(response)
- validator.validate(json)
- validator = self.get_validator("apiDeclaration")
- response = self.client.get("/swagger/api-docs/a-view")
- json = parse_json(response)
- self.assertIn("KitchenSinkSerializer", json['models'])
- validator.validate(json)
-
- def test_yaml_parameters(self):
- class MockApiView(APIView):
- """
- ---
- GET:
- parameters:
- - name: bob
- type: string
- enum:
- - taco
- - enchilada
- - name: rob
- type: string
- defaultValue: 'lewis'
- - name: i1
- type: integer
- format: int32
- - name: i2
- type: integer
- format: int64
- - name: idurp
- type: integer
- format: smokey
- minimum: 1
- maximum: 100
- - name: mandy
- type: string
- allowMultiple: true
- uniqueItems: true
- - name: sandy
- type: array
- items:
- type: integer
- - name: candy
- type: array
- items:
- type: integer
- uniqueItems: true
- """
- def get(self, request):
- pass
- self.url_patterns = patterns(
- '',
- url(r'^a-view/?$', MockApiView.as_view(), name='a test view'),
- url(r'^swagger/', include('rest_framework_swagger.urls')),
- )
- urls = import_module(settings.ROOT_URLCONF)
- urls.urlpatterns = self.url_patterns
-
- validator = self.get_validator("resourceListing")
- response = self.client.get("/swagger/api-docs/")
- json = parse_json(response)
- validator.validate(json)
- validator = self.get_validator("apiDeclaration")
- response = self.client.get("/swagger/api-docs/a-view")
- json = parse_json(response)
- validator.validate(json)
- self.assertEqual('object', json['apis'][0]['operations'][0]['type'])
- parameters = json['apis'][0]['operations'][0]['parameters']
- self.assertNotIn('format', parameters[0])
- self.assertNotIn('defaultValue', parameters[0])
- self.assertNotIn('format', parameters[1])
- self.assertEqual('lewis', parameters[1]['defaultValue'])
- self.assertEqual('', parameters[1]['description'])
- self.assertEqual('i1', parameters[2]['name'])
- self.assertEqual('int32', parameters[2]['format'])
- self.assertEqual('i2', parameters[3]['name'])
- self.assertEqual('int64', parameters[3]['format'])
- self.assertEqual('idurp', parameters[4]['name'])
- self.assertEqual('int32', parameters[4]['format'])
- self.assertEqual('sandy', parameters[6]['name'])
- self.assertEqual('integer', parameters[6]['items']['type'])
- self.assertEqual('int32', parameters[6]['items']['format'])
- self.assertEqual('candy', parameters[7]['name'])
- self.assertIn('uniqueItems', parameters[7])
-
- def test_raw_array(self):
- class MockApiView(APIView):
- """
- ---
- GET:
- parameters:
- - name: bob
- type: array
- items:
- type: string
- """
- def get(self, request):
- pass
- self.url_patterns = patterns(
- '',
- url(r'^a-view/?$', MockApiView.as_view(), name='a test view'),
- url(r'^swagger/', include('rest_framework_swagger.urls')),
- )
- urls = import_module(settings.ROOT_URLCONF)
- urls.urlpatterns = self.url_patterns
-
- validator = self.get_validator("resourceListing")
- response = self.client.get("/swagger/api-docs/")
- json = parse_json(response)
- validator.validate(json)
- validator = self.get_validator("apiDeclaration")
- response = self.client.get("/swagger/api-docs/a-view")
- json = parse_json(response)
- validator.validate(json)
-
- def test_old_parameters(self):
-
- class MockApiView(APIView):
- def get(self, request):
- """
- taco -- a place to my food
- """
- pass
- self.url_patterns = patterns(
- '',
- url(r'^a-view/?$', MockApiView.as_view(), name='a test view'),
- url(r'^swagger/', include('rest_framework_swagger.urls')),
- )
- urls = import_module(settings.ROOT_URLCONF)
- urls.urlpatterns = self.url_patterns
-
- validator = self.get_validator("resourceListing")
- response = self.client.get("/swagger/api-docs/")
- json = parse_json(response)
- validator.validate(json)
- validator = self.get_validator("apiDeclaration")
- response = self.client.get("/swagger/api-docs/a-view")
- json = parse_json(response)
- validator.validate(json)
diff --git a/rest_framework_swagger/views.py b/rest_framework_swagger/views.py
index 48cde540..ee47e7f4 100644
--- a/rest_framework_swagger/views.py
+++ b/rest_framework_swagger/views.py
@@ -1,4 +1,5 @@
import json
+from django import VERSION as DJANGO_VERSION
from django.utils import six
from django.conf import settings
@@ -6,7 +7,8 @@
from django.utils.safestring import mark_safe
from django.utils.encoding import smart_text
from django.shortcuts import render_to_response
-from django.template import RequestContext
+if DJANGO_VERSION < (1, 11):
+ from django.template import RequestContext
from django.core.exceptions import PermissionDenied
from .compat import import_string
@@ -80,8 +82,12 @@ def get(self, request, *args, **kwargs):
json.dumps(getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken'))),
}
}
- response = render_to_response(
- template_name, RequestContext(request, data))
+ if DJANGO_VERSION < (1, 11):
+ response = render_to_response(
+ template_name, RequestContext(request, data))
+ else:
+ data['request'] = request
+ response = render_to_response(template_name, data)
return response
diff --git a/setup.cfg b/setup.cfg
index 5e409001..82690218 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,5 @@
[wheel]
universal = 1
+
+[flake8]
+exclude = *.ropeproject
diff --git a/tox.ini b/tox.ini
index 941bb24a..14635f24 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,22 +1,15 @@
[tox]
envlist =
py27-flake8,
- {py27,py33,py34}-django1.8-drf{2.3,2.4,3.0,3.1,3.2,3.3},
- # Django 1.9+ requires Python 2.7/3.4+ and django-rest-framework 3.3+.
- {py27,py34}-django1.9-drf3.3,
- {py35}-django{1.8,1.9}-drf3.3
+ {py27,py35}-django{1.8,1.9}-drf{3.3,3.4},
[testenv]
commands = ./runtests.py --stop
deps =
django1.8: Django>=1.8,<1.9
django1.9: Django>=1.9,<1.10
- drf2.3: djangorestframework>=2.3,<2.4
- drf2.4: djangorestframework>=2.4,<2.5
- drf3.0: djangorestframework>=3.0,<3.1
- drf3.1: djangorestframework>=3.1,<3.2
- drf3.2: djangorestframework>=3.2,<3.3
drf3.3: djangorestframework>=3.3,<3.4
+ drf3.4: djangorestframework>=3.4
{py27,py33,py34}-django{1.8}-drf{2.3,2.4}: PyYAML==3.10
py27: functools32==3.2.3-2
docutils==0.11
@@ -25,7 +18,7 @@ deps =
nose==1.3.0
Markdown==2.5.1
mock==1.0.1
- django-nose==1.4
+ django-nose==1.4.4
coverage==3.6
django-filter==0.10.0
jsonschema==2.5