Compare commits

...
6 Commits
3 changed files with 1303 additions and 1452 deletions
+1239 -1401
View File
File diff suppressed because it is too large Load Diff
+62 -49
View File
@@ -1,5 +1,5 @@
// swagger.js
// version 2.0.13
// version 2.0.17
var __bind = function(fn, me){
return function(){
@@ -67,7 +67,7 @@ SwaggerApi.prototype.build = function() {
}
},
response: function(resp) {
var responseObj = resp.obj;
var responseObj = resp.obj || JSON.parse(resp.data);
_this.swaggerVersion = responseObj.swaggerVersion;
if (_this.swaggerVersion === "1.2") {
return _this.buildFromSpec(responseObj);
@@ -284,8 +284,8 @@ var SwaggerResource = function(resourceObj, api) {
accept: "application/json"
},
on: {
response: function(response) {
var responseObj = response.obj;
response: function(resp) {
var responseObj = resp.obj || JSON.parse(resp.data);
return _this.addApiDeclaration(responseObj);
},
error: function(response) {
@@ -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;
@@ -392,7 +392,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes,
}
if (o.errorResponses) {
responseMessages = o.errorResponses;
for (j = 0; j < responseMessages.length; j++) {
for (var j = 0; j < responseMessages.length; j++) {
r = responseMessages[j];
r.message = r.reason;
r.reason = null;
@@ -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());
}
@@ -478,11 +478,11 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
var returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
if (!modelsToIgnore)
modelsToIgnore = [];
modelsToIgnore.push(this);
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];
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel) === -1) {
if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -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.indexOf(prop.refModel.name) === -1)) {
result = this.refModel.createJSONSample(modelsToIgnore);
} else {
if (this.isCollection) {
@@ -615,13 +615,16 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
}
for(i = 0; i < parameters.length; i ++) {
var param = parameters[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;
// for 1.1 compatibility
var type = param.type || param.dataType;
if(type === 'array') {
type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']';
}
if(type.toLowerCase() === 'boolean') {
param.allowableValues = {};
@@ -636,7 +639,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
param.allowableValues = {};
param.allowableValues.descriptiveValues = [];
for(j = 0; j < enumValue.length; j++) {
for(var j = 0; j < enumValue.length; j++) {
var v = enumValue[j];
if(param.defaultValue != null) {
param.allowableValues.descriptiveValues.push ({
@@ -652,26 +655,28 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
}
}
}
if(param.allowableValues != null) {
else if(param.allowableValues != null) {
if(param.allowableValues.valueType === "RANGE")
param.isRange = true;
else
param.isList = true;
if(param.allowableValues != null) {
param.allowableValues.descriptiveValues = [];
for(j = 0; j < param.allowableValues.values; j++){
var v = param.allowableValues.values[j];
if(param.defaultValue != null) {
param.allowableValues.descriptiveValues.push ({
value: String(v),
isDefault: (v === param.defaultValue)
});
}
else {
param.allowableValues.descriptiveValues.push ({
value: String(v),
isDefault: false
});
if(param.allowableValues.values) {
for(var j = 0; j < param.allowableValues.values.length; j++){
var v = param.allowableValues.values[j];
if(param.defaultValue != null) {
param.allowableValues.descriptiveValues.push ({
value: String(v),
isDefault: (v === param.defaultValue)
});
}
else {
param.allowableValues.descriptiveValues.push ({
value: String(v),
isDefault: false
});
}
}
}
}
@@ -686,7 +691,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
}
SwaggerOperation.prototype.isListType = function(type) {
if (type.indexOf('[') >= 0) {
if (type && type.indexOf('[') >= 0) {
return type.substring(type.indexOf('[') + 1, type.indexOf(']'));
} else {
return void 0;
@@ -763,7 +768,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 +811,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 ++){
var param = params[i];
if (param.paramType === 'path') {
if(args[param.name]) {
@@ -821,12 +826,13 @@ 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 !== '')
queryParams += "&";
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
if(args[param.name] !== undefined)
queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]);
}
}
if ((queryParams != null) && queryParams.length > 0)
@@ -853,7 +859,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 +875,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 +914,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 +964,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 +1101,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 +1113,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 +1198,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
@@ -1263,7 +1275,7 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
if (obj.url.indexOf('?') > 0)
obj.url = obj.url + "&" + this.name + "=" + this.value;
else
obj.url = obj.url + "?" + this.name + "=" + this.value;
obj.url = obj.url + "?" + this.name + "=" + this.value;
return true;
} else if (this.type === "header") {
obj.headers[this.name] = this.value;
@@ -1279,11 +1291,10 @@ var PasswordAuthorization = function(name, username, password) {
this.username = username;
this.password = password;
this._btoa = null;
if (typeof window !== 'undefined')
return this._btoa = btoa;
this._btoa = btoa;
else
return this._btoa = require("btoa");
this._btoa = require("btoa");
};
PasswordAuthorization.prototype.apply = function(obj, authorizations) {
@@ -1296,6 +1307,8 @@ var e = (typeof window !== 'undefined' ? window : exports);
e.SwaggerHttp = SwaggerHttp;
e.SwaggerRequest = SwaggerRequest;
e.authorizations = new SwaggerAuthorizations();
e.ApiKeyAuthorization = ApiKeyAuthorization;
e.PasswordAuthorization = PasswordAuthorization;
e.JQueryHttpClient = JQueryHttpClient;
e.ShredHttpClient = ShredHttpClient;
e.SwaggerOperation = SwaggerOperation;
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "2.0.7",
"version": "2.0.11",
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
"scripts": {
"build": "PATH=$PATH:./node_modules/.bin cake dist",
@@ -19,7 +19,7 @@
"readmeFilename": "README.md",
"dependencies": {
"coffee-script": "~1.5.0",
"swagger-client": "2.0.13",
"swagger-client": "2.0.18",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}