Commit df20d2bd authored by Tony Tam's avatar Tony Tam
Browse files

fix for #263

parent e72dbd6b
......@@ -624,7 +624,7 @@ function program2(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 ";
buffer += escapeExpression(stack1) + "'/>\n <div class=\"parameter-content-type\" />\n ";
return buffer;}
function program4(depth0,data) {
......@@ -1492,11 +1492,16 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};
SwaggerUi.prototype.load = function() {
var _ref;
var url, _ref;
if ((_ref = this.mainView) != null) {
_ref.clear();
}
this.headerView.update(this.options.url);
url = this.options.url;
if (url.indexOf("http") !== 0) {
url = this.buildUrl(window.location.href.toString(), url);
}
this.options.url = url;
this.headerView.update(url);
this.api = new SwaggerApi(this.options);
this.api.build();
return this.api;
......@@ -1525,6 +1530,18 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
}, 400);
};
SwaggerUi.prototype.buildUrl = function(base, url) {
var parts;
console.log("base is " + base);
parts = base.split("/");
base = parts[0] + "//" + parts[2];
if (url.indexOf("/") === 0) {
return base + url;
} else {
return base + "/" + url;
}
};
SwaggerUi.prototype.showMessage = function(data) {
if (data == null) {
data = '';
......@@ -1712,7 +1729,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
OperationView.prototype.initialize = function() {};
OperationView.prototype.render = function() {
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1;
var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
isMethodSubmissionSupported = true;
if (!isMethodSubmissionSupported) {
this.model.isReadOnly = true;
......@@ -1737,18 +1754,29 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};
contentTypeModel.consumes = this.model.consumes;
contentTypeModel.produces = this.model.produces;
_ref = this.model.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
console.log("looking at " + param.dataType);
if (param.dataType.toLowerCase() === 'file') {
if (!contentTypeModel.consumes) {
console.log("set content type ");
contentTypeModel.consumes = 'multipart/form-data';
}
}
}
responseContentTypeView = new ResponseContentTypeView({
model: contentTypeModel
});
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
_ref = this.model.parameters;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
param = _ref[_i];
_ref1 = this.model.parameters;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
param = _ref1[_j];
this.addParameter(param, contentTypeModel.consumes);
}
_ref1 = this.model.responseMessages;
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
statusCode = _ref1[_j];
_ref2 = this.model.responseMessages;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
statusCode = _ref2[_k];
this.addStatusCode(statusCode);
}
return this;
......@@ -1799,7 +1827,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
opts = {
parent: this
};
_ref = form.find(".body-textarea,.parameter");
_ref = form.find("input");
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
o = _ref[_i];
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
......@@ -1997,7 +2025,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
if (this.model.paramType === 'body') {
this.model.isBody = true;
}
if (this.model.dataType === 'file') {
if (this.model.dataType.toLowerCase() === 'file') {
this.model.isFile = true;
}
template = this.template();
......
This diff is collapsed.
......@@ -41,7 +41,12 @@ class SwaggerUi extends Backbone.Router
load: ->
# Initialize the API object
@mainView?.clear()
@headerView.update(@options.url)
url = @options.url
if url.indexOf("http") isnt 0
url = @buildUrl(window.location.href.toString(), url)
@options.url = url
@headerView.update(url)
@api = new SwaggerApi(@options)
@api.build()
@api
......@@ -62,6 +67,16 @@ class SwaggerUi extends Backbone.Router
400
)
buildUrl: (base, url) ->
console.log "base is " + base
parts = base.split("/")
base = parts[0] + "//" + parts[2]
if url.indexOf("/") is 0
base + url
else
base + "/" + url
# Shows message on topbar of the ui
showMessage: (data = '') ->
$('#message-bar').removeClass 'message-fail'
......
......@@ -31,6 +31,13 @@ class OperationView extends Backbone.View
contentTypeModel.consumes = @model.consumes
contentTypeModel.produces = @model.produces
for param in @model.parameters
console.log "looking at " + param.dataType
if param.dataType.toLowerCase() == 'file'
if !contentTypeModel.consumes
console.log "set content type "
contentTypeModel.consumes = 'multipart/form-data'
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
......@@ -74,7 +81,7 @@ class OperationView extends Backbone.View
#if(o.value? && jQuery.trim(o.value).length > 0)
#map[o.name] = o.value
for o in form.find(".body-textarea,.parameter")
for o in form.find("input")
if(o.value? && jQuery.trim(o.value).length > 0)
map[o.name] = encodeURI(o.value)
......
......@@ -3,7 +3,7 @@ class ParameterView extends Backbone.View
render: ->
@model.isBody = true if @model.paramType == 'body'
@model.isFile = true if @model.dataType == 'file'
@model.isFile = true if @model.dataType.toLowerCase() == 'file'
template = @template()
$(@el).html(template(@model))
......
......@@ -4,6 +4,7 @@
{{#if isBody}}
{{#if isFile}}
<input type="file" name='{{name}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if defaultValue}}
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment