Skip to content

Commit

Permalink
merged from develop, added fix for swagger-api#627
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Dec 3, 2014
1 parent 142a3b8 commit 37214c3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 14 deletions.
19 changes: 14 additions & 5 deletions lib/swagger-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,11 @@ SwaggerClient.prototype.idFromOp = function(path, httpMethod, op) {
return (op.operationId);
}
else {
return path.substring(1).replace(/\//g, "_").replace(/\{/g, "").replace(/\}/g, "") + "_" + httpMethod;
return path.substring(1)
.replace(/\//g, "_")
.replace(/\{/g, "")
.replace(/\}/g, "")
.replace(/\./g, "_") + "_" + httpMethod;
}
}

Expand Down Expand Up @@ -658,8 +662,8 @@ Operation.prototype.getType = function (param) {
str = 'integer';
else if(type === 'integer' && format === 'int64')
str = 'long';
else if(type === 'integer' && typeof format === 'undefined')
str = 'long';
else if(type === 'integer')
str = 'integer'
else if(type === 'string' && format === 'date-time')
str = 'date-time';
else if(type === 'string' && format === 'date')
Expand All @@ -668,7 +672,7 @@ Operation.prototype.getType = function (param) {
str = 'float';
else if(type === 'number' && format === 'double')
str = 'double';
else if(type === 'number' && typeof format === 'undefined')
else if(type === 'number')
str = 'double';
else if(type === 'boolean')
str = 'boolean';
Expand Down Expand Up @@ -878,7 +882,12 @@ Operation.prototype.execute = function(arg1, arg2, arg3, arg4, parent) {
// todo append?
args.body = encoded;
}
var url = this.scheme + '://' + this.host + this.basePath + requestUrl + querystring;
var url = this.scheme + '://' + this.host;

if(this.basePath !== '/')
url += this.basePath;

url += requestUrl + querystring;

var obj = {
url: url,
Expand Down
15 changes: 10 additions & 5 deletions lib/swagger.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// swagger.js
// version 2.0.46
// version 2.0.47

(function () {

Expand Down Expand Up @@ -992,9 +992,14 @@
output += encodeURIComponent(param[j]);
}
queryParams += encodeURIComponent(param.name) + '=' + output;
}
else {
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
}
else {
if (args[param.name]) {
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
} else {
if (param.required)
throw "" + param.name + " is a required query param.";
}
}
}
}
Expand Down Expand Up @@ -1275,7 +1280,7 @@
else if (this.type === "DELETE")
body = "{}";
else if (this.type != "DELETE")
accepts = null;
consumes = null;
}

if (consumes && this.operation.consumes) {
Expand Down
19 changes: 16 additions & 3 deletions swagger-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ function program4(depth0,data) {
function program5(depth0,data) {

var buffer = "", stack1;
buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
buffer += "\n <textarea class='body-textarea required' placeholder='(required)' name='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
Expand All @@ -1005,7 +1005,7 @@ function program5(depth0,data) {
function program7(depth0,data) {

var buffer = "", stack1;
buffer += "\n <textarea class='body-textarea' placeholder='(required)' name='";
buffer += "\n <textarea class='body-textarea required' placeholder='(required)' name='";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
Expand Down Expand Up @@ -1949,6 +1949,19 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return error_free = false;
}
});
form.find("textarea.required").each(function() {
var _this = this;
$(this).removeClass("error");
if (jQuery.trim($(this).val()) === "") {
$(this).addClass("error");
$(this).wiggle({
callback: function() {
return $(_this).focus();
}
});
return error_free = false;
}
});
if (error_free) {
map = {};
opts = {
Expand Down Expand Up @@ -2262,7 +2275,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};

OperationView.prototype.toggleOperationContent = function() {
var elem;
elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_content");
elem = $('#' + Docs.escapeResourceName(this.model.parentId + "_" + this.model.nickname + "_content"));
if (elem.is(':visible')) {
return Docs.collapseOperation(elem);
} else {
Expand Down
2 changes: 1 addition & 1 deletion swagger-ui.min.js

Large diffs are not rendered by default.

0 comments on commit 37214c3

Please sign in to comment.