-
Notifications
You must be signed in to change notification settings - Fork 762
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,8 +350,8 @@ SwaggerResource.prototype.addModels = function(models) { | |
} | ||
} | ||
var output = []; | ||
for (var i = 0; i < this.modelsArray; i++) { | ||
model = this.modelsArray[_i]; | ||
for (var i = 0; i < this.modelsArray.length; i++) { | ||
model = this.modelsArray[i]; | ||
output.push(model.setReferencedModels(this.models)); | ||
} | ||
return output; | ||
|
@@ -450,7 +450,7 @@ var SwaggerModel = function(modelName, obj) { | |
|
||
SwaggerModel.prototype.setReferencedModels = function(allModels) { | ||
var results = []; | ||
for (i = 0; i < this.properties.length; i++) { | ||
for (var i = 0; i < this.properties.length; i++) { | ||
var property = this.properties[i]; | ||
var type = property.type || property.dataType; | ||
if (allModels[type] != null) | ||
|
@@ -465,7 +465,7 @@ SwaggerModel.prototype.setReferencedModels = function(allModels) { | |
|
||
SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) { | ||
var propertiesStr = []; | ||
for (i = 0; i < this.properties.length; i++) { | ||
for (var i = 0; i < this.properties.length; i++) { | ||
prop = this.properties[i]; | ||
propertiesStr.push(prop.toString()); | ||
} | ||
|
@@ -480,7 +480,7 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) { | |
modelsToIgnore = []; | ||
modelsToIgnore.push(this); | ||
|
||
for (i = 0; i < this.properties.length; i++) { | ||
for (var i = 0; i < this.properties.length; i++) { | ||
prop = this.properties[i]; | ||
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel) === -1) { | ||
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore)); | ||
|
@@ -493,7 +493,7 @@ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) { | |
var result = {}; | ||
var modelsToIgnore = (modelsToIgnore||[]) | ||
modelsToIgnore.push(this.name); | ||
for (i = 0; i < this.properties.length; i++) { | ||
for (var i = 0; i < this.properties.length; i++) { | ||
prop = this.properties[i]; | ||
result[prop.name] = prop.getSampleValue(modelsToIgnore); | ||
} | ||
|
@@ -534,7 +534,7 @@ var SwaggerModelProperty = function(name, obj) { | |
|
||
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) { | ||
var result; | ||
if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) { | ||
if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === undefined)) { | ||
result = this.refModel.createJSONSample(modelsToIgnore); | ||
} else { | ||
if (this.isCollection) { | ||
|
@@ -615,7 +615,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not | |
this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models); | ||
} | ||
|
||
for(i = 0; i < this.parameters.length; i ++) { | ||
for(var i = 0; i < this.parameters.length; i ++) { | ||
var param = this.parameters[i]; | ||
// might take this away | ||
param.name = param.name || param.type || param.dataType; | ||
|
@@ -763,7 +763,7 @@ SwaggerOperation.prototype["do"] = function(args, opts, callback, error) { | |
} | ||
|
||
var possibleParams = []; | ||
for(i = 0; i < this.parameters.length; i++) { | ||
for(var i = 0; i < this.parameters.length; i++) { | ||
var param = this.parameters[i]; | ||
if(param.paramType === 'header') { | ||
if(args[param.name]) | ||
|
@@ -806,7 +806,7 @@ SwaggerOperation.prototype.pathXml = function() { | |
SwaggerOperation.prototype.urlify = function(args) { | ||
var url = this.resource.basePath + this.pathJson(); | ||
var params = this.parameters; | ||
for(i = 0; i < params.length; i ++){ | ||
for(var i = 0; i < params.length; i ++){ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fehguy
Author
Contributor
|
||
var param = params[i]; | ||
if (param.paramType === 'path') { | ||
if(args[param.name]) { | ||
|
@@ -821,7 +821,7 @@ SwaggerOperation.prototype.urlify = function(args) { | |
} | ||
|
||
var queryParams = ""; | ||
for(i = 0; i < params.length; i ++){ | ||
for(var i = 0; i < params.length; i ++){ | ||
var param = params[i]; | ||
if(param.paramType === 'query') { | ||
if(queryParams !== '') | ||
|
@@ -853,7 +853,7 @@ SwaggerOperation.prototype.getHeaderParams = function(args) { | |
SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) { | ||
var matchingParams = {}; | ||
var params = this.parameters; | ||
for (i = 0; i < params.length; i++) { | ||
for (var i = 0; i < params.length; i++) { | ||
param = params[i]; | ||
if (args && args[param.name]) | ||
matchingParams[param.name] = args[param.name]; | ||
|
@@ -869,7 +869,7 @@ SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) { | |
SwaggerOperation.prototype.help = function() { | ||
var msg = ""; | ||
var params = this.parameters; | ||
for (i = 0; i < params.length; i++) { | ||
for (var i = 0; i < params.length; i++) { | ||
var param = params[i]; | ||
if (msg !== "") | ||
msg += "\n"; | ||
|
@@ -908,7 +908,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal | |
var params = this.operation.parameters; | ||
|
||
|
||
for(i = 0; i < params.length; i++) { | ||
for(var i = 0; i < params.length; i++) { | ||
var param = params[i]; | ||
if(param.paramType === "form") | ||
formParams.push(param); | ||
|
@@ -958,7 +958,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal | |
var possibleParams = {}; | ||
var values = {}; | ||
|
||
for(i = 0; i < formParams.length; i++){ | ||
for(var i = 0; i < formParams.length; i++){ | ||
var param = formParams[i]; | ||
values[param.name] = param; | ||
} | ||
|
@@ -1095,7 +1095,7 @@ JQueryHttpClient.prototype.execute = function(obj) { | |
headers = {}; | ||
headerArray = response.getAllResponseHeaders().split(":"); | ||
|
||
for(i = 0; i < headerArray.length / 2; i++) | ||
for(var i = 0; i < headerArray.length / 2; i++) | ||
headers[headerArray[i] = headerArray[i+1]]; | ||
|
||
out = { | ||
|
@@ -1107,9 +1107,15 @@ JQueryHttpClient.prototype.execute = function(obj) { | |
headers: headers | ||
}; | ||
|
||
if(response._headers["Content-Type"] && response._headers["Content-Type"].indexOf("application/json") == 0 && | ||
response.content.data && response.content.data !== "") { | ||
out.obj = JSON.parse(response.responseText); | ||
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null) | ||
|
||
if(contentType != null) { | ||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | ||
if(response.responseText && response.responseText !== "") | ||
out.obj = JSON.parse(response.responseText); | ||
else | ||
out.obj = {} | ||
} | ||
} | ||
|
||
if(response.status >= 200 && response.status < 300) | ||
|
@@ -1186,7 +1192,7 @@ ShredHttpClient.prototype.execute = function(obj) { | |
var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null) | ||
|
||
if(contentType != null) { | ||
if(contentType.indexOf("application/json") == 0) { | ||
if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { | ||
if(response.content.data && response.content.data !== "") | ||
out.obj = JSON.parse(response.content.data); | ||
else | ||
|
In JavaScript, all variables (including
var i
) should be declared at the beginning of the function (closure) and thefor
statement should just initialize itfor(i = 0; i < iterations; ++i)
. There are a couple of places in this file where 2 separate for loops occur inside the same closure, each declaring the same variable (this is one of them).