diff --git a/README.md b/README.md
index 0d98ef91..5a655c13 100644
--- a/README.md
+++ b/README.md
@@ -32,8 +32,18 @@ You may choose to customize Swagger UI for your organization. Here is an overvie
- src/main/html: the html files, some images and css
- src/main/javascript: some legacy javascript referenced by CofffeeScript code
+### HTTP Methods and API Invocation
+swagger-ui supports invocation of all HTTP methods APIs but only GET methods APIs are enabled by default. You can choose to enable other HTTP methods like POST, PUT and DELETE. This can be enabled by setting the supportedSubmitMethods parameter when creating SwaggerUI instance.
+
+For example if you wanted to enable GET, POST and PUT but not for DELETE, you'd set this as:
+
+```supportedSubmitMethods: ['get', 'post', 'put']
+```
+
+_Note that for POST/PUT body, you'd need to paste in the request data in an appropriate format which your service can unmarshall_
+
### Header Parameters
-Because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to false when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/overhaul/src/main/html/index.html#L45).
+header parameters aere supported. However because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to false when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/overhaul/src/main/html/index.html#L45).
diff --git a/dist/css/screen.css b/dist/css/screen.css
index 228b024c..07773f9e 100644
--- a/dist/css/screen.css
+++ b/dist/css/screen.css
@@ -104,6 +104,11 @@ div.heading_with_menu {
box-sizing: border-box;
margin-top: 10px; }
+.body-textarea {
+ width: 300px;
+ height: 100px;
+}
+
p {
line-height: 1.4em;
padding: 0 0 10px 0;
diff --git a/dist/index.html b/dist/index.html
index 417d2ec5..34673e6d 100644
--- a/dist/index.html
+++ b/dist/index.html
@@ -45,7 +45,8 @@
discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",
apiKey:"special-key",
dom_id:"swagger-ui-container",
- supportHeaderParams: false
+ supportHeaderParams: false,
+ supportedSubmitMethods: ['get', 'post', 'put']
});
window.swaggerUi.load();
diff --git a/dist/lib/swagger.js b/dist/lib/swagger.js
index 6ea1c201..883a0178 100644
--- a/dist/lib/swagger.js
+++ b/dist/lib/swagger.js
@@ -35,6 +35,7 @@
this.verbose = options.verbose;
}
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
+ this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
if (options.success != null) {
this.success = options.success;
}
@@ -371,6 +372,10 @@
return this.resource.api.supportHeaderParams;
};
+ SwaggerOperation.prototype.supportedSubmitMethods = function() {
+ return this.resource.api.supportedSubmitMethods;
+ };
+
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
if (includeApiKey == null) {
includeApiKey = true;
diff --git a/dist/swagger-ui.js b/dist/swagger-ui.js
index 2d82f389..a9cffb47 100644
--- a/dist/swagger-ui.js
+++ b/dist/swagger-ui.js
@@ -191,6 +191,11 @@ function program1(depth0,data) {
function program3(depth0,data) {
+ return "\n ";}
+
+function program5(depth0,data) {
+
+
return "\n
\n ";}
buffer += "\n \n \n
\n Parameters \n \n \n \n Parameter \n Value \n Description \n \n \n \n\n \n
\n ";
- foundHelper = helpers.isGetMethod;
- stack1 = foundHelper || depth0.isGetMethod;
+ foundHelper = helpers.isReadOnly;
+ stack1 = foundHelper || depth0.isReadOnly;
stack2 = helpers['if'];
tmp1 = self.program(3, program3, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.noop;
+ tmp1.inverse = self.program(5, program5, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n \n \n
Request URL \n
\n
Response Body \n
\n
Response Code \n
\n
Response Headers \n \n
\n \n \n \n";
@@ -320,8 +325,65 @@ templates['param'] = template(function (Handlebars,depth0,helpers,partials,data)
function program1(depth0,data) {
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(2, program2, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(4, program4, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n \n ";
+ return buffer;}
+function program2(depth0,data) {
+
var buffer = "", stack1;
- buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n \n ";
+ return buffer;}
+
+function program6(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(7, program7, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(9, program9, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program7(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n \n ";
+ buffer += escapeExpression(stack1) + "'/>\n ";
return buffer;}
-function program3(depth0,data) {
+function program9(depth0,data) {
var buffer = "", stack1;
- buffer += "\n \n ";
+ buffer += escapeExpression(stack1) + "' placeholder='' type='text' value=''/>\n ";
return buffer;}
buffer += "";
@@ -350,17 +412,17 @@ function program3(depth0,data) {
stack1 = foundHelper || depth0.name;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
- buffer += escapeExpression(stack1) + " \n\n ";
- foundHelper = helpers.defaultValue;
- stack1 = foundHelper || depth0.defaultValue;
+ buffer += escapeExpression(stack1) + " \n\n \n ";
+ foundHelper = helpers.isBody;
+ stack1 = foundHelper || depth0.isBody;
stack2 = helpers['if'];
tmp1 = self.program(1, program1, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(3, program3, data);
+ tmp1.inverse = self.program(6, program6, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
- buffer += "\n \n";
+ buffer += "\n\n \n";
foundHelper = helpers.description;
stack1 = foundHelper || depth0.description;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -542,8 +604,65 @@ templates['param_required'] = template(function (Handlebars,depth0,helpers,parti
function program1(depth0,data) {
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(2, program2, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(4, program4, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n \n ";
+ return buffer;}
+function program2(depth0,data) {
+
var buffer = "", stack1;
- buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
+ else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); }
+ buffer += escapeExpression(stack1) + "\n ";
+ return buffer;}
+
+function program4(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n \n ";
+ return buffer;}
+
+function program6(depth0,data) {
+
+ var buffer = "", stack1, stack2;
+ buffer += "\n ";
+ foundHelper = helpers.defaultValue;
+ stack1 = foundHelper || depth0.defaultValue;
+ stack2 = helpers['if'];
+ tmp1 = self.program(7, program7, data);
+ tmp1.hash = {};
+ tmp1.fn = tmp1;
+ tmp1.inverse = self.program(9, program9, data);
+ stack1 = stack2.call(depth0, stack1, tmp1);
+ if(stack1 || stack1 === 0) { buffer += stack1; }
+ buffer += "\n ";
+ return buffer;}
+function program7(depth0,data) {
+
+ var buffer = "", stack1;
+ buffer += "\n \n ";
+ buffer += escapeExpression(stack1) + "'/>\n ";
return buffer;}
-function program3(depth0,data) {
+function program9(depth0,data) {
var buffer = "", stack1;
- buffer += "\n \n ";
+ buffer += escapeExpression(stack1) + "' placeholder='(required)' type='text' value=''/>\n ";
return buffer;}
buffer += " ";
@@ -573,13 +692,13 @@ function program3(depth0,data) {
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); }
buffer += escapeExpression(stack1) + " \n\n ";
- foundHelper = helpers.defaultValue;
- stack1 = foundHelper || depth0.defaultValue;
+ foundHelper = helpers.isBody;
+ stack1 = foundHelper || depth0.isBody;
stack2 = helpers['if'];
tmp1 = self.program(1, program1, data);
tmp1.hash = {};
tmp1.fn = tmp1;
- tmp1.inverse = self.program(3, program3, data);
+ tmp1.inverse = self.program(6, program6, data);
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n \n\n ";
@@ -935,7 +1054,11 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
OperationView.prototype.initialize = function() {};
OperationView.prototype.render = function() {
- var param, _i, _len, _ref;
+ var isMethodSubmissionSupported, param, _i, _len, _ref;
+ isMethodSubmissionSupported = jQuery.inArray(this.model.httpMethod, this.model.supportedSubmitMethods()) >= 0;
+ if (!isMethodSubmissionSupported) {
+ this.model.isReadOnly = true;
+ }
$(this.el).html(Handlebars.templates.operation(this.model));
_ref = this.model.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@@ -950,13 +1073,13 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
paramView = new ParameterView({
model: param,
tagName: 'tr',
- readOnly: !this.model.isGetMethod
+ readOnly: this.model.isReadOnly
});
return $('.operation-params', $(this.el)).append(paramView.render().el);
};
OperationView.prototype.submitOperation = function() {
- var error_free, form, headerParams, invocationUrl, map, o, obj, _i, _len, _ref,
+ var bodyParam, error_free, form, headerParams, invocationUrl, map, o, obj, param, _i, _j, _len, _len1, _ref, _ref1,
_this = this;
form = $('.sandbox', $(this.el));
error_free = true;
@@ -982,6 +1105,15 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
map[o.name] = o.value;
}
}
+ bodyParam = null;
+ _ref1 = this.model.parameters;
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
+ param = _ref1[_j];
+ if (param.paramType === 'body') {
+ bodyParam = map[param.name];
+ }
+ }
+ log("bodyParam = " + bodyParam);
headerParams = null;
invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
log('submitting ' + invocationUrl);
@@ -991,6 +1123,7 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
type: this.model.httpMethod,
url: invocationUrl,
headers: headerParams,
+ data: bodyParam,
dataType: 'json',
error: function(xhr, textStatus, error) {
return _this.showErrorStatus(xhr, textStatus, error);
@@ -1074,6 +1207,9 @@ templates['resource'] = template(function (Handlebars,depth0,helpers,partials,da
ParameterView.prototype.render = function() {
var template;
+ if (this.model.paramType === 'body') {
+ this.model.isBody = true;
+ }
template = this.template();
$(this.el).html(template(this.model));
return this;
diff --git a/dist/swagger-ui.min.js b/dist/swagger-ui.min.js
index ce1f857c..fccfa49c 100644
--- a/dist/swagger-ui.min.js
+++ b/dist/swagger-ui.min.js
@@ -1 +1 @@
-$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}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_"+b+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){$("#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){$("#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+a+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+a+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n Implementation Notes \n ";k=f.notes;u=k||w.notes;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"notes",{hash:{}})}}t+=m(u)+"
\n ";return t}function c(u,t){return"\n \n "}l+="\n \n \n \n \n ";k=f.notes;d=k||q.notes;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.noop;d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n
\n
\n
Request URL \n
\n
Response Body \n
\n
Response Code \n
\n
Response Headers \n \n
\n
\n \n \n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n \n ";return t}function c(w,v){var t="",u;t+="\n \n ";return t}l+="";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+" \n\n ";k=f.defaultValue;d=k||q.defaultValue;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n \n";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}l+=m(d)+" \n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n ";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) \n ";return y}function w(B,A){var y="",z;y+="\n ";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)+" \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+" \n\n \n ";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 \n \n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}u+=d(k)+" \n\n";return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.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- \n";h=d.description;c=h||n.description;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"description",{hash:{}})}}i+=j(c)+" \n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.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- \n";h=d.description;c=h||n.description;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"description",{hash:{}})}}i+=j(c)+" \n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n \n ";return t}function c(w,v){var t="",u;t+="\n \n ";return t}l+="";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+" \n\n ";k=f.defaultValue;d=k||q.defaultValue;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n \n\n ";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}l+=m(d)+" \n \n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var d,h,b,g,a,f,c={}.hasOwnProperty,e=function(l,j){for(var i in j){if(c.call(j,i)){l[i]=j[i]}}function k(){this.constructor=l}k.prototype=j.prototype;l.prototype=new k;l.__super__=j.prototype;return l};f=(function(j){e(i,j);i.name="SwaggerUi";function i(){return i.__super__.constructor.apply(this,arguments)}i.prototype.routes={"":"load"};i.prototype.dom_id="swagger_ui";i.prototype.options=null;i.prototype.api=null;i.prototype.headerView=null;i.prototype.mainView=null;i.prototype.initialize=function(k){var l=this;if(k==null){k={}}Backbone.history.start({pushState:true});if(k.dom_id!=null){this.dom_id=k.dom_id;delete k.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=k;this.options.success=function(){return l.render()};this.options.progress=function(m){return l.showMessage(m)};this.options.failure=function(m){return l.onLoadFailure(m)};this.headerView=new d({el:$("#header")});return this.headerView.on("update-swagger-ui",function(m){return l.updateSwaggerUi(m)})};i.prototype.updateSwaggerUi=function(k){this.options.discoveryUrl=k.discoveryUrl;this.options.apiKey=k.apiKey;return this.load()};i.prototype.load=function(){var k;if((k=this.mainView)!=null){k.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};i.prototype.render=function(){var k=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();return setTimeout(function(){return Docs.shebang()},400)};i.prototype.showMessage=function(k){if(k==null){k=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(k)};i.prototype.onLoadFailure=function(k){if(k==null){k=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");return $("#message-bar").html(k)};return i})(Backbone.Router);window.SwaggerUi=f;d=(function(j){e(i,j);i.name="HeaderView";function i(){return i.__super__.constructor.apply(this,arguments)}i.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"};i.prototype.initialize=function(){};i.prototype.showPetStore=function(k){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",apiKey:"special-key"})};i.prototype.showWordnikDev=function(k){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};i.prototype.showCustomOnKeyup=function(k){if(k.keyCode===13){return this.showCustom()}};i.prototype.showCustom=function(k){if(k!=null){k.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};i.prototype.update=function(l,m,k){if(k==null){k=false}$("#input_baseUrl").val(l);$("#input_apiKey").val(m);if(k){return this.trigger("update-swagger-ui",{discoveryUrl:l,apiKey:m})}};return i})(Backbone.View);h=(function(i){e(j,i);j.name="MainView";function j(){return j.__super__.constructor.apply(this,arguments)}j.prototype.initialize=function(){};j.prototype.render=function(){var n,m,k,l;$(this.el).html(Handlebars.templates.main(this.model));l=this.model.resourcesArray;for(m=0,k=l.length;m0){k[m.name]=m.value}}t=null;v=this.model.supportHeaderParams()?(t=this.model.getHeaderParams(k),this.model.urlify(k,false)):this.model.urlify(k,true);log("submitting "+v);$(".request_url",$(this.el)).html(""+v+" ");$(".response_throbber",$(this.el)).show();q={type:this.model.httpMethod,url:v,headers:t,dataType:"json",error:function(w,x,o){return r.showErrorStatus(w,x,o)},success:function(o){return r.showResponse(o)},complete:function(o){return r.showCompleteStatus(o)}};if(q.type.toLowerCase()==="post"||q.type.toLowerCase()==="put"){q.contentType="application/json"}return jQuery.ajax(q)}};i.prototype.hideResponse=function(k){if(k!=null){k.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};i.prototype.showResponse=function(k){var l;l=JSON.stringify(k,null,"\t").replace(/\n/g," ");return $(".response_body",$(this.el)).html(l)};i.prototype.showErrorStatus=function(k){return this.showStatus(k)};i.prototype.showCompleteStatus=function(k){return this.showStatus(k)};i.prototype.showStatus=function(m){var l;try{l=""+JSON.stringify(JSON.parse(m.responseText),null,2).replace(/\n/g," ")+" "}catch(k){l=" [unable to parse as json; raw response below] "+m.responseText+" "}$(".response_code",$(this.el)).html(""+m.status+" ");$(".response_body",$(this.el)).html(l);$(".response_headers",$(this.el)).html(""+m.getAllResponseHeaders()+" ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();return $(".response_throbber",$(this.el)).hide()};i.prototype.toggleOperationContent=function(){var k;k=$("#"+this.model.resourceName+"_"+this.model.nickname+"_"+this.model.httpMethod+"_content");if(k.is(":visible")){return Docs.collapseOperation(k)}else{return Docs.expandOperation(k)}};return i})(Backbone.View);g=(function(j){e(i,j);i.name="ParameterView";function i(){return i.__super__.constructor.apply(this,arguments)}i.prototype.initialize=function(){};i.prototype.render=function(){var k;k=this.template();$(this.el).html(k(this.model));return this};i.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 i})(Backbone.View)}).call(this);
\ No newline at end of file
+$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}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_"+b+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){$("#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){$("#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+a+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+a+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,k,t){q=q||g.helpers;var r="",i,f,h,o,n=this,e="function",p=q.helperMissing,c=void 0,d=this.escapeExpression;function m(x,w){var u="",v;u+="\n Implementation Notes \n ";h=q.notes;v=h||x.notes;if(typeof v===e){v=v.call(x,{hash:{}})}else{if(v===c){v=p.call(x,"notes",{hash:{}})}}u+=d(v)+"
\n ";return u}function l(v,u){return"\n "}function j(v,u){return"\n \n "}r+="\n \n \n \n \n ";h=q.notes;i=h||s.notes;f=q["if"];o=n.program(1,m,t);o.hash={};o.fn=o;o.inverse=n.noop;i=f.call(s,i,o);if(i||i===0){r+=i}r+="\n
\n
\n
Request URL \n
\n
Response Body \n
\n
Response Code \n
\n
Response Headers \n \n
\n
\n \n \n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,w){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(B,A){var x="",z,y;x+="\n ";i=t.defaultValue;z=i||B.defaultValue;y=t["if"];r=q.program(2,o,A);r.hash={};r.fn=r;r.inverse=q.program(4,n,A);z=y.call(B,z,r);if(z||z===0){x+=z}x+="\n \n ";return x}function o(A,z){var x="",y;x+="\n \n ";return x}function n(A,z){var x="",y;x+="\n \n ";return x}function l(B,A){var x="",z,y;x+="\n ";i=t.defaultValue;z=i||B.defaultValue;y=t["if"];r=q.program(7,k,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);z=y.call(B,z,r);if(z||z===0){x+=z}x+="\n ";return x}function k(A,z){var x="",y;x+="\n \n ";return x}function f(A,z){var x="",y;x+="\n \n ";return x}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" \n\n \n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,w);r.hash={};r.fn=r;r.inverse=q.program(6,l,w);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n \n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}u+=d(j)+" \n\n";return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n ";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) \n ";return y}function w(B,A){var y="",z;y+="\n ";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)+" \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+" \n\n \n ";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 \n \n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}u+=d(k)+" \n\n";return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.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- \n";h=d.description;c=h||n.description;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"description",{hash:{}})}}i+=j(c)+" \n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.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- \n";h=d.description;c=h||n.description;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"description",{hash:{}})}}i+=j(c)+" \n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,w){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(B,A){var x="",z,y;x+="\n ";i=t.defaultValue;z=i||B.defaultValue;y=t["if"];r=q.program(2,o,A);r.hash={};r.fn=r;r.inverse=q.program(4,n,A);z=y.call(B,z,r);if(z||z===0){x+=z}x+="\n \n ";return x}function o(A,z){var x="",y;x+="\n \n ";return x}function n(A,z){var x="",y;x+="\n \n ";return x}function l(B,A){var x="",z,y;x+="\n ";i=t.defaultValue;z=i||B.defaultValue;y=t["if"];r=q.program(7,k,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);z=y.call(B,z,r);if(z||z===0){x+=z}x+="\n ";return x}function k(A,z){var x="",y;x+="\n \n ";return x}function f(A,z){var x="",y;x+="\n \n ";return x}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+" \n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,w);r.hash={};r.fn=r;r.inverse=q.program(6,l,w);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n \n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}u+=d(j)+" \n \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+="\n\n";return i})})();(function(){var d,h,b,g,a,f,c={}.hasOwnProperty,e=function(l,j){for(var i in j){if(c.call(j,i)){l[i]=j[i]}}function k(){this.constructor=l}k.prototype=j.prototype;l.prototype=new k;l.__super__=j.prototype;return l};f=(function(j){e(i,j);i.name="SwaggerUi";function i(){return i.__super__.constructor.apply(this,arguments)}i.prototype.routes={"":"load"};i.prototype.dom_id="swagger_ui";i.prototype.options=null;i.prototype.api=null;i.prototype.headerView=null;i.prototype.mainView=null;i.prototype.initialize=function(k){var l=this;if(k==null){k={}}Backbone.history.start({pushState:true});if(k.dom_id!=null){this.dom_id=k.dom_id;delete k.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
')}this.options=k;this.options.success=function(){return l.render()};this.options.progress=function(m){return l.showMessage(m)};this.options.failure=function(m){return l.onLoadFailure(m)};this.headerView=new d({el:$("#header")});return this.headerView.on("update-swagger-ui",function(m){return l.updateSwaggerUi(m)})};i.prototype.updateSwaggerUi=function(k){this.options.discoveryUrl=k.discoveryUrl;this.options.apiKey=k.apiKey;return this.load()};i.prototype.load=function(){var k;if((k=this.mainView)!=null){k.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};i.prototype.render=function(){var k=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({model:this.api,el:$("#"+this.dom_id)}).render();this.showMessage();return setTimeout(function(){return Docs.shebang()},400)};i.prototype.showMessage=function(k){if(k==null){k=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(k)};i.prototype.onLoadFailure=function(k){if(k==null){k=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");return $("#message-bar").html(k)};return i})(Backbone.Router);window.SwaggerUi=f;d=(function(j){e(i,j);i.name="HeaderView";function i(){return i.__super__.constructor.apply(this,arguments)}i.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"};i.prototype.initialize=function(){};i.prototype.showPetStore=function(k){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",apiKey:"special-key"})};i.prototype.showWordnikDev=function(k){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};i.prototype.showCustomOnKeyup=function(k){if(k.keyCode===13){return this.showCustom()}};i.prototype.showCustom=function(k){if(k!=null){k.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};i.prototype.update=function(l,m,k){if(k==null){k=false}$("#input_baseUrl").val(l);$("#input_apiKey").val(m);if(k){return this.trigger("update-swagger-ui",{discoveryUrl:l,apiKey:m})}};return i})(Backbone.View);h=(function(i){e(j,i);j.name="MainView";function j(){return j.__super__.constructor.apply(this,arguments)}j.prototype.initialize=function(){};j.prototype.render=function(){var n,m,k,l;$(this.el).html(Handlebars.templates.main(this.model));l=this.model.resourcesArray;for(m=0,k=l.length;m=0;if(!l){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));m=this.model.parameters;for(n=0,k=m.length;n0){k[n.name]=n.value}}z=null;q=this.model.parameters;for(r=0,l=q.length;r"+A+"");$(".response_throbber",$(this.el)).show();u={type:this.model.httpMethod,url:A,headers:x,data:z,dataType:"json",error:function(B,C,o){return v.showErrorStatus(B,C,o)},success:function(o){return v.showResponse(o)},complete:function(o){return v.showCompleteStatus(o)}};if(u.type.toLowerCase()==="post"||u.type.toLowerCase()==="put"){u.contentType="application/json"}return jQuery.ajax(u)}};i.prototype.hideResponse=function(k){if(k!=null){k.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};i.prototype.showResponse=function(k){var l;l=JSON.stringify(k,null,"\t").replace(/\n/g," ");return $(".response_body",$(this.el)).html(l)};i.prototype.showErrorStatus=function(k){return this.showStatus(k)};i.prototype.showCompleteStatus=function(k){return this.showStatus(k)};i.prototype.showStatus=function(m){var l;try{l=""+JSON.stringify(JSON.parse(m.responseText),null,2).replace(/\n/g," ")+" "}catch(k){l=" [unable to parse as json; raw response below] "+m.responseText+" "}$(".response_code",$(this.el)).html(""+m.status+" ");$(".response_body",$(this.el)).html(l);$(".response_headers",$(this.el)).html(""+m.getAllResponseHeaders()+" ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();return $(".response_throbber",$(this.el)).hide()};i.prototype.toggleOperationContent=function(){var k;k=$("#"+this.model.resourceName+"_"+this.model.nickname+"_"+this.model.httpMethod+"_content");if(k.is(":visible")){return Docs.collapseOperation(k)}else{return Docs.expandOperation(k)}};return i})(Backbone.View);g=(function(j){e(i,j);i.name="ParameterView";function i(){return i.__super__.constructor.apply(this,arguments)}i.prototype.initialize=function(){};i.prototype.render=function(){var k;if(this.model.paramType==="body"){this.model.isBody=true}k=this.template();$(this.el).html(k(this.model));return this};i.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 i})(Backbone.View)}).call(this);
\ No newline at end of file
diff --git a/lib/swagger.js b/lib/swagger.js
index 6ea1c201..883a0178 100644
--- a/lib/swagger.js
+++ b/lib/swagger.js
@@ -35,6 +35,7 @@
this.verbose = options.verbose;
}
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
+ this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
if (options.success != null) {
this.success = options.success;
}
@@ -371,6 +372,10 @@
return this.resource.api.supportHeaderParams;
};
+ SwaggerOperation.prototype.supportedSubmitMethods = function() {
+ return this.resource.api.supportedSubmitMethods;
+ };
+
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
if (includeApiKey == null) {
includeApiKey = true;
diff --git a/src/main/coffeescript/view/OperationView.coffee b/src/main/coffeescript/view/OperationView.coffee
index 9ae88b9a..5d249fe3 100644
--- a/src/main/coffeescript/view/OperationView.coffee
+++ b/src/main/coffeescript/view/OperationView.coffee
@@ -8,6 +8,9 @@ class OperationView extends Backbone.View
initialize: ->
render: ->
+ isMethodSubmissionSupported = jQuery.inArray(@model.httpMethod, @model.supportedSubmitMethods()) >= 0
+ @model.isReadOnly = true unless isMethodSubmissionSupported
+
$(@el).html(Handlebars.templates.operation(@model))
# Render each parameter
@@ -16,9 +19,10 @@ class OperationView extends Backbone.View
addParameter: (param) ->
# Render a parameter
- paramView = new ParameterView({model: param, tagName: 'tr', readOnly: !@model.isGetMethod})
+ paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
$('.operation-params', $(@el)).append paramView.render().el
+
submitOperation: ->
# Check for errors
form = $('.sandbox', $(@el))
@@ -38,6 +42,13 @@ class OperationView extends Backbone.View
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = o.value
+ bodyParam = null
+ for param in @model.parameters
+ if param.paramType is 'body'
+ bodyParam = map[param.name]
+
+ log "bodyParam = " + bodyParam
+
headerParams = null
invocationUrl =
if @model.supportHeaderParams()
@@ -56,7 +67,7 @@ class OperationView extends Backbone.View
type: @model.httpMethod
url: invocationUrl
headers: headerParams
- # data: JSON.stringify(@body)
+ data: bodyParam
dataType: 'json'
error: (xhr, textStatus, error) =>
@showErrorStatus(xhr, textStatus, error)
diff --git a/src/main/coffeescript/view/ParameterView.coffee b/src/main/coffeescript/view/ParameterView.coffee
index 7eb4c245..8146dbd3 100644
--- a/src/main/coffeescript/view/ParameterView.coffee
+++ b/src/main/coffeescript/view/ParameterView.coffee
@@ -2,6 +2,8 @@ class ParameterView extends Backbone.View
initialize: ->
render: ->
+ @model.isBody = true if @model.paramType == 'body'
+
template = @template()
$(@el).html(template(@model))
@
diff --git a/src/main/html/css/screen.css b/src/main/html/css/screen.css
index 228b024c..07773f9e 100644
--- a/src/main/html/css/screen.css
+++ b/src/main/html/css/screen.css
@@ -104,6 +104,11 @@ div.heading_with_menu {
box-sizing: border-box;
margin-top: 10px; }
+.body-textarea {
+ width: 300px;
+ height: 100px;
+}
+
p {
line-height: 1.4em;
padding: 0 0 10px 0;
diff --git a/src/main/html/index.html b/src/main/html/index.html
index 417d2ec5..34673e6d 100644
--- a/src/main/html/index.html
+++ b/src/main/html/index.html
@@ -45,7 +45,8 @@
discoveryUrl:"http://petstore.swagger.wordnik.com/api/resources.json",
apiKey:"special-key",
dom_id:"swagger-ui-container",
- supportHeaderParams: false
+ supportHeaderParams: false,
+ supportedSubmitMethods: ['get', 'post', 'put']
});
window.swaggerUi.load();
diff --git a/src/main/template/operation.handlebars b/src/main/template/operation.handlebars
index 3e770ae4..d1a72faf 100644
--- a/src/main/template/operation.handlebars
+++ b/src/main/template/operation.handlebars
@@ -36,7 +36,8 @@
- {{#if isGetMethod}}
+ {{#if isReadOnly}}
+ {{else}}