app/assets/javascripts/lib/swagger.js in swagger-ui_rails-0.1.3 vs app/assets/javascripts/lib/swagger.js in swagger-ui_rails-0.1.4

- old
+ new

@@ -1,11 +1,17 @@ // Generated by CoffeeScript 1.6.3 (function() { - var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, + var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, log, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + log = function() { + if (window.console) { + return console.log.apply(console, arguments); + } + }; + SwaggerApi = (function() { SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json"; SwaggerApi.prototype.debug = false; @@ -51,11 +57,13 @@ this.progress('fetching resource list: ' + this.url); obj = { useJQuery: this.useJQuery, url: this.url, method: "get", - headers: {}, + headers: { + accept: "application/json" + }, on: { error: function(response) { if (_this.url.substring(0, 4) !== 'http') { return _this.fail('Please specify the protocol for ' + _this.url); } else if (response.status === 0) { @@ -302,11 +310,13 @@ this.api.progress('fetching resource ' + this.name + ': ' + this.url); obj = { url: this.url, method: "get", useJQuery: this.useJQuery, - headers: {}, + headers: { + accept: "application/json" + }, on: { error: function(response) { return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")"); }, response: function(response) { @@ -527,11 +537,11 @@ } modelsToIgnore.push(this); _ref1 = this.properties; for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { prop = _ref1[_j]; - if ((prop.refModel != null) && (modelsToIgnore[prop.refModel] !== 'undefined') === -1) { + if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel) === -1) { returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore)); } } return returnVal; }; @@ -590,22 +600,38 @@ var result; if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) { result = this.refModel.createJSONSample(modelsToIgnore); } else { if (this.isCollection) { - result = this.refDataType; + result = this.toSampleValue(this.refDataType); } else { - result = this.dataType; + result = this.toSampleValue(this.dataType); } } if (this.isCollection) { return [result]; } else { return result; } }; + SwaggerModelProperty.prototype.toSampleValue = function(value) { + var result; + if (value === "integer") { + result = 0; + } else if (value === "boolean") { + result = false; + } else if (value === "double") { + result = 0.0; + } else if (value === "string") { + result = ""; + } else { + result = value; + } + return result; + }; + SwaggerModelProperty.prototype.toString = function() { var req, str; req = this.required ? 'propReq' : 'propOpt'; str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>'; if (!this.required) { @@ -995,11 +1021,11 @@ var _i, _len, _ref, _results; _ref = this.operation.parameters; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { param = _ref[_i]; - if (type.toLowerCase() === "file") { + if (typeof type !== 'undefined' && type.toLowerCase() === "file") { _results.push(param); } } return _results; }).call(this)).length > 0) { @@ -1449,6 +1475,6 @@ this.SwaggerHttp = SwaggerHttp; this.authorizations = new SwaggerAuthorizations(); -}).call(this); +}).call(this); \ No newline at end of file