fix for #263
This commit is contained in:
52
dist/swagger-ui.js
vendored
52
dist/swagger-ui.js
vendored
@@ -624,7 +624,7 @@ function program2(depth0,data) {
|
|||||||
stack1 = foundHelper || depth0.name;
|
stack1 = foundHelper || depth0.name;
|
||||||
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
|
||||||
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { 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;}
|
return buffer;}
|
||||||
|
|
||||||
function program4(depth0,data) {
|
function program4(depth0,data) {
|
||||||
@@ -1492,11 +1492,16 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
};
|
};
|
||||||
|
|
||||||
SwaggerUi.prototype.load = function() {
|
SwaggerUi.prototype.load = function() {
|
||||||
var _ref;
|
var url, _ref;
|
||||||
if ((_ref = this.mainView) != null) {
|
if ((_ref = this.mainView) != null) {
|
||||||
_ref.clear();
|
_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 = new SwaggerApi(this.options);
|
||||||
this.api.build();
|
this.api.build();
|
||||||
return this.api;
|
return this.api;
|
||||||
@@ -1525,6 +1530,18 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
}, 400);
|
}, 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) {
|
SwaggerUi.prototype.showMessage = function(data) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = '';
|
data = '';
|
||||||
@@ -1712,7 +1729,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
OperationView.prototype.initialize = function() {};
|
OperationView.prototype.initialize = function() {};
|
||||||
|
|
||||||
OperationView.prototype.render = 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;
|
isMethodSubmissionSupported = true;
|
||||||
if (!isMethodSubmissionSupported) {
|
if (!isMethodSubmissionSupported) {
|
||||||
this.model.isReadOnly = true;
|
this.model.isReadOnly = true;
|
||||||
@@ -1737,18 +1754,29 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
};
|
};
|
||||||
contentTypeModel.consumes = this.model.consumes;
|
contentTypeModel.consumes = this.model.consumes;
|
||||||
contentTypeModel.produces = this.model.produces;
|
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({
|
responseContentTypeView = new ResponseContentTypeView({
|
||||||
model: contentTypeModel
|
model: contentTypeModel
|
||||||
});
|
});
|
||||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||||
_ref = this.model.parameters;
|
_ref1 = this.model.parameters;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
param = _ref[_i];
|
param = _ref1[_j];
|
||||||
this.addParameter(param, contentTypeModel.consumes);
|
this.addParameter(param, contentTypeModel.consumes);
|
||||||
}
|
}
|
||||||
_ref1 = this.model.responseMessages;
|
_ref2 = this.model.responseMessages;
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||||
statusCode = _ref1[_j];
|
statusCode = _ref2[_k];
|
||||||
this.addStatusCode(statusCode);
|
this.addStatusCode(statusCode);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@@ -1799,7 +1827,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
opts = {
|
opts = {
|
||||||
parent: this
|
parent: this
|
||||||
};
|
};
|
||||||
_ref = form.find(".body-textarea,.parameter");
|
_ref = form.find("input");
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
o = _ref[_i];
|
o = _ref[_i];
|
||||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
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') {
|
if (this.model.paramType === 'body') {
|
||||||
this.model.isBody = true;
|
this.model.isBody = true;
|
||||||
}
|
}
|
||||||
if (this.model.dataType === 'file') {
|
if (this.model.dataType.toLowerCase() === 'file') {
|
||||||
this.model.isFile = true;
|
this.model.isFile = true;
|
||||||
}
|
}
|
||||||
template = this.template();
|
template = this.template();
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -41,7 +41,12 @@ class SwaggerUi extends Backbone.Router
|
|||||||
load: ->
|
load: ->
|
||||||
# Initialize the API object
|
# Initialize the API object
|
||||||
@mainView?.clear()
|
@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 = new SwaggerApi(@options)
|
||||||
@api.build()
|
@api.build()
|
||||||
@api
|
@api
|
||||||
@@ -62,6 +67,16 @@ class SwaggerUi extends Backbone.Router
|
|||||||
400
|
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
|
# Shows message on topbar of the ui
|
||||||
showMessage: (data = '') ->
|
showMessage: (data = '') ->
|
||||||
$('#message-bar').removeClass 'message-fail'
|
$('#message-bar').removeClass 'message-fail'
|
||||||
|
|||||||
@@ -31,6 +31,13 @@ class OperationView extends Backbone.View
|
|||||||
contentTypeModel.consumes = @model.consumes
|
contentTypeModel.consumes = @model.consumes
|
||||||
contentTypeModel.produces = @model.produces
|
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})
|
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||||
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
|
$('.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)
|
#if(o.value? && jQuery.trim(o.value).length > 0)
|
||||||
#map[o.name] = o.value
|
#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)
|
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||||
map[o.name] = encodeURI(o.value)
|
map[o.name] = encodeURI(o.value)
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ class ParameterView extends Backbone.View
|
|||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
@model.isBody = true if @model.paramType == 'body'
|
@model.isBody = true if @model.paramType == 'body'
|
||||||
@model.isFile = true if @model.dataType == 'file'
|
@model.isFile = true if @model.dataType.toLowerCase() == 'file'
|
||||||
|
|
||||||
template = @template()
|
template = @template()
|
||||||
$(@el).html(template(@model))
|
$(@el).html(template(@model))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
{{#if isBody}}
|
{{#if isBody}}
|
||||||
{{#if isFile}}
|
{{#if isFile}}
|
||||||
<input type="file" name='{{name}}'/>
|
<input type="file" name='{{name}}'/>
|
||||||
|
<div class="parameter-content-type" />
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if defaultValue}}
|
{{#if defaultValue}}
|
||||||
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
|
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
|
||||||
|
|||||||
Reference in New Issue
Block a user