Compare commits

...
7 Commits
Author SHA1 Message Date
Tony Tam b336076a19 updated version 2014-02-12 07:38:49 -08:00
Tony Tam b8943665a2 updated client to 2.0.13 2014-02-12 07:37:41 -08:00
Tony Tam 0c0ffc569f updated swagger-client 2014-02-03 22:25:57 -08:00
Tony Tam 18ce470f12 merge of #369, https://github.com/wordnik/swagger-js/issues/74 2014-02-03 17:51:05 -08:00
Tony Tam 53593b796e fix for #387 2014-02-03 16:20:07 -08:00
Tony Tam 2378b176f5 fix for #388 2014-02-03 08:28:22 -08:00
Tony Tam 7dd5142df2 fix for #381 2014-01-27 07:13:12 -08:00
7 changed files with 1373 additions and 1418 deletions
+66 -13
View File
@@ -1,9 +1,15 @@
// 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";
@@ -53,7 +59,9 @@
useJQuery: this.useJQuery,
url: this.url,
method: "get",
headers: {},
headers: {
accept: "application/json"
},
on: {
error: function(response) {
if (_this.url.substring(0, 4) !== 'http') {
@@ -304,7 +312,9 @@
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 + ")");
@@ -529,7 +539,7 @@
_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));
}
}
@@ -592,9 +602,9 @@
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) {
@@ -604,6 +614,22 @@
}
};
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';
@@ -997,7 +1023,7 @@
_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);
}
}
@@ -1188,19 +1214,46 @@
}
cb = obj.on;
res = {
error: function(response) {
error: function(raw) {
var headers, out;
if (obj) {
return cb.error(response);
headers = raw._headers;
out = {
headers: headers,
url: raw.request.url,
method: raw.request.method,
status: raw.status,
data: raw.content.data
};
return cb.error(out);
}
},
redirect: function(response) {
redirect: function(raw) {
var headers, out;
if (obj) {
return cb.redirect(response);
headers = raw._headers;
out = {
headers: headers,
url: raw.request.url,
method: raw.request.method,
status: raw.status,
data: raw.content.data
};
return cb.redirect(out);
}
},
307: function(response) {
307: function(raw) {
var headers, out;
if (obj) {
return cb.redirect(response);
headers = raw._headers;
out = {
headers: headers,
url: raw.request.url,
method: raw.request.method,
status: raw.status,
data: raw.content.data
};
return cb.redirect(out);
}
},
response: function(raw) {
+22 -11
View File
@@ -1281,13 +1281,24 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
SwaggerUi.prototype.buildUrl = function(base, url) {
var parts;
var endOfPath, parts;
log("base is " + base);
parts = base.split("/");
base = parts[0] + "//" + parts[2];
if (url.indexOf("/") === 0) {
parts = base.split("/");
base = parts[0] + "//" + parts[2];
return base + url;
} else {
endOfPath = base.length;
if (base.indexOf("?") > -1) {
endOfPath = Math.min(endOfPath, base.indexOf("?"));
}
if (base.indexOf("#") > -1) {
endOfPath = Math.min(endOfPath, base.indexOf("#"));
}
base = base.substring(0, endOfPath);
if (base.indexOf("/", base.length - 1) !== -1) {
return base + url;
}
return base + "/" + url;
}
};
@@ -1682,16 +1693,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
OperationView.prototype.wrap = function(data) {
var o,
_this = this;
var headerArray, headers, i, o, _i, _ref5, _ref6;
headers = {};
headerArray = data.getAllResponseHeaders().split(":");
for (i = _i = 0, _ref5 = headerArray.length / 2, _ref6 = 2.; _ref6 > 0 ? _i <= _ref5 : _i >= _ref5; i = _i += _ref6) {
headers[headerArray[i]] = headerArray[i + 1];
}
o = {};
o.content = {};
o.content.data = data.responseText;
o.getHeaders = function() {
return {
"Content-Type": data.headers("Content-Type")
};
};
o.headers = headers;
o.request = {};
o.request.url = this.invocationUrl;
o.status = data.status;
@@ -1818,7 +1829,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var code, content, contentType, headers, pre, response_body;
content = response.data;
headers = response.headers;
contentType = headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
contentType = headers && headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
if (!content) {
code = $('<code />').text("no content");
pre = $('<pre class="json" />').append(code);
+1 -1
View File
File diff suppressed because one or more lines are too long
+1262 -1384
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "2.0.4",
"version": "2.0.7",
"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.9",
"swagger-client": "2.0.13",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}
+11 -4
View File
@@ -69,13 +69,20 @@ class SwaggerUi extends Backbone.Router
buildUrl: (base, url) ->
log "base is " + base
parts = base.split("/")
base = parts[0] + "//" + parts[2]
if url.indexOf("/") is 0
parts = base.split("/")
base = parts[0] + "//" + parts[2]
base + url
else
base + "/" + url
endOfPath = base.length
if base.indexOf("?") > -1
endOfPath = Math.min(endOfPath, base.indexOf("?"))
if base.indexOf("#") > -1
endOfPath = Math.min(endOfPath, base.indexOf("#"))
base = base.substring(0, endOfPath);
if base.indexOf( "/", base.length - 1 ) isnt -1
return base + url
return base + "/" + url
# Shows message on topbar of the ui
showMessage: (data = '') ->
@@ -169,12 +169,18 @@ class OperationView extends Backbone.View
false
# end of file-upload nastiness
# wraps a jquery response as a shred response
# wraps a jquery response as a shred response
wrap: (data) ->
headers = {}
headerArray = data.getAllResponseHeaders().split(":")
for i in [0..headerArray.length/2] by (2)
headers[headerArray[i]] = headerArray[i+1]
o = {}
o.content = {}
o.content.data = data.responseText
o.getHeaders = () => {"Content-Type": data.headers("Content-Type")}
o.headers = headers
o.request = {}
o.request.url = @invocationUrl
o.status = data.status
@@ -276,7 +282,7 @@ class OperationView extends Backbone.View
headers = response.headers
# if server is nice, and sends content-type back, we can use it
contentType = if headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
if !content
code = $('<code />').text("no content")