updated swagger-js client, support for IE8
This commit is contained in:
15
dist/index.html
vendored
15
dist/index.html
vendored
@@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Swagger UI</title>
|
<title>Swagger UI</title>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||||
@@ -23,25 +23,20 @@
|
|||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
if(console) {
|
log("Loaded SwaggerUI")
|
||||||
console.log("Loaded SwaggerUI")
|
|
||||||
}
|
|
||||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||||
},
|
},
|
||||||
onFailure: function(data) {
|
onFailure: function(data) {
|
||||||
if(console) {
|
log("Unable to Load SwaggerUI");
|
||||||
console.log("Unable to Load SwaggerUI");
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
docExpansion: "none"
|
docExpansion: "none"
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(function() {
|
||||||
var key = $('#input_apiKey')[0].value;
|
var key = $('#input_apiKey')[0].value;
|
||||||
console.log("key: " + key);
|
log("key: " + key);
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
console.log("added key " + key);
|
log("added key " + key);
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
198
dist/lib/swagger.js
vendored
198
dist/lib/swagger.js
vendored
@@ -1,7 +1,8 @@
|
|||||||
// Generated by CoffeeScript 1.6.3
|
// Generated by CoffeeScript 1.6.3
|
||||||
(function() {
|
(function() {
|
||||||
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__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; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
|
|
||||||
SwaggerApi.prototype.info = null;
|
SwaggerApi.prototype.info = null;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.useJQuery = null;
|
||||||
|
|
||||||
function SwaggerApi(url, options) {
|
function SwaggerApi(url, options) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {};
|
options = {};
|
||||||
@@ -47,6 +50,7 @@
|
|||||||
_this = this;
|
_this = this;
|
||||||
this.progress('fetching resource list: ' + this.url);
|
this.progress('fetching resource list: ' + this.url);
|
||||||
obj = {
|
obj = {
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
headers: {},
|
headers: {},
|
||||||
@@ -62,14 +66,14 @@
|
|||||||
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
response: function(rawResponse) {
|
response: function(response) {
|
||||||
var response;
|
var responseObj;
|
||||||
response = JSON.parse(rawResponse.content.data);
|
responseObj = JSON.parse(response.data);
|
||||||
_this.swaggerVersion = response.swaggerVersion;
|
_this.swaggerVersion = responseObj.swaggerVersion;
|
||||||
if (_this.swaggerVersion === "1.2") {
|
if (_this.swaggerVersion === "1.2") {
|
||||||
return _this.buildFromSpec(response);
|
return _this.buildFromSpec(responseObj);
|
||||||
} else {
|
} else {
|
||||||
return _this.buildFrom1_1Spec(response);
|
return _this.buildFrom1_1Spec(responseObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
|
|
||||||
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
||||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||||
console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
||||||
if (response.apiVersion != null) {
|
if (response.apiVersion != null) {
|
||||||
this.apiVersion = response.apiVersion;
|
this.apiVersion = response.apiVersion;
|
||||||
}
|
}
|
||||||
@@ -241,15 +245,15 @@
|
|||||||
_ref = this.apis;
|
_ref = this.apis;
|
||||||
for (resource_name in _ref) {
|
for (resource_name in _ref) {
|
||||||
resource = _ref[resource_name];
|
resource = _ref[resource_name];
|
||||||
console.log(resource_name);
|
log(resource_name);
|
||||||
_ref1 = resource.operations;
|
_ref1 = resource.operations;
|
||||||
for (operation_name in _ref1) {
|
for (operation_name in _ref1) {
|
||||||
operation = _ref1[operation_name];
|
operation = _ref1[operation_name];
|
||||||
console.log(" " + operation.nickname);
|
log(" " + operation.nickname);
|
||||||
_ref2 = operation.parameters;
|
_ref2 = operation.parameters;
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
parameter = _ref2[_i];
|
parameter = _ref2[_i];
|
||||||
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,6 +287,7 @@
|
|||||||
this.operationsArray = [];
|
this.operationsArray = [];
|
||||||
this.modelsArray = [];
|
this.modelsArray = [];
|
||||||
this.models = {};
|
this.models = {};
|
||||||
|
this.rawModels = {};
|
||||||
if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
|
if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
|
||||||
this.addApiDeclaration(resourceObj);
|
this.addApiDeclaration(resourceObj);
|
||||||
} else {
|
} else {
|
||||||
@@ -298,15 +303,16 @@
|
|||||||
obj = {
|
obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
headers: {},
|
headers: {},
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
||||||
},
|
},
|
||||||
response: function(rawResponse) {
|
response: function(response) {
|
||||||
var response;
|
var responseObj;
|
||||||
response = JSON.parse(rawResponse.content.data);
|
responseObj = JSON.parse(response.data);
|
||||||
return _this.addApiDeclaration(response);
|
return _this.addApiDeclaration(responseObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -372,6 +378,7 @@
|
|||||||
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
||||||
this.modelsArray.push(swaggerModel);
|
this.modelsArray.push(swaggerModel);
|
||||||
this.models[modelName] = swaggerModel;
|
this.models[modelName] = swaggerModel;
|
||||||
|
this.rawModels[modelName] = models[modelName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ref = this.modelsArray;
|
_ref = this.modelsArray;
|
||||||
@@ -522,7 +529,7 @@
|
|||||||
_ref1 = this.properties;
|
_ref1 = this.properties;
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
prop = _ref1[_j];
|
prop = _ref1[_j];
|
||||||
if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
|
if ((prop.refModel != null) && (modelsToIgnore[prop.refModel] !== 'undefined') === -1) {
|
||||||
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,7 +588,7 @@
|
|||||||
|
|
||||||
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||||
var result;
|
var result;
|
||||||
if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
|
if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) {
|
||||||
result = this.refModel.createJSONSample(modelsToIgnore);
|
result = this.refModel.createJSONSample(modelsToIgnore);
|
||||||
} else {
|
} else {
|
||||||
if (this.isCollection) {
|
if (this.isCollection) {
|
||||||
@@ -776,19 +783,19 @@
|
|||||||
}
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
error = function(xhr, textStatus, error) {
|
error = function(xhr, textStatus, error) {
|
||||||
return console.log(xhr, textStatus, error);
|
return log(xhr, textStatus, error);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(data) {
|
callback = function(response) {
|
||||||
var content;
|
var content;
|
||||||
content = null;
|
content = null;
|
||||||
if (data.content != null) {
|
if (response != null) {
|
||||||
content = data.content.data;
|
content = response.data;
|
||||||
} else {
|
} else {
|
||||||
content = "no data";
|
content = "no data";
|
||||||
}
|
}
|
||||||
return console.log("default callback: " + content);
|
return log("default callback: " + content);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
params = {};
|
params = {};
|
||||||
@@ -1005,8 +1012,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && this.operation.consumes) {
|
if (requestContentType && this.operation.consumes) {
|
||||||
if (this.operation.consumes.indexOf(requestContentType) === -1) {
|
if (this.operation.consumes[requestContentType] === 'undefined') {
|
||||||
console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
|
log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||||
if (this.requestContentType === null) {
|
if (this.requestContentType === null) {
|
||||||
requestContentType = this.operation.consumes[0];
|
requestContentType = this.operation.consumes[0];
|
||||||
}
|
}
|
||||||
@@ -1023,8 +1030,8 @@
|
|||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
}
|
}
|
||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces[responseContentType] === 'undefined') {
|
||||||
console.log("server can't produce " + responseContentType);
|
log("server can't produce " + responseContentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
@@ -1073,6 +1080,7 @@
|
|||||||
method: this.type,
|
method: this.type,
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: body,
|
body: body,
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.errorCallback(response, _this.opts.parent);
|
return _this.errorCallback(response, _this.opts.parent);
|
||||||
@@ -1102,7 +1110,6 @@
|
|||||||
obj.canceled = true;
|
obj.canceled = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(obj);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,13 +1135,15 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
SwaggerHttp = (function() {
|
SwaggerHttp = (function() {
|
||||||
|
function SwaggerHttp() {}
|
||||||
|
|
||||||
SwaggerHttp.prototype.Shred = null;
|
SwaggerHttp.prototype.Shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.shred = null;
|
SwaggerHttp.prototype.shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.content = null;
|
SwaggerHttp.prototype.content = null;
|
||||||
|
|
||||||
function SwaggerHttp() {
|
SwaggerHttp.prototype.initShred = function() {
|
||||||
var identity, toString,
|
var identity, toString,
|
||||||
_this = this;
|
_this = this;
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
@@ -1151,22 +1160,147 @@
|
|||||||
};
|
};
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
this.content = require("./shred/content");
|
this.content = require("./shred/content");
|
||||||
this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
return this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
parser: identity,
|
parser: identity,
|
||||||
stringify: toString
|
stringify: toString
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
return this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
parser: identity,
|
parser: identity,
|
||||||
stringify: toString
|
stringify: toString
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SwaggerHttp.prototype.execute = function(obj) {
|
SwaggerHttp.prototype.execute = function(obj) {
|
||||||
|
if (this.isIE() || obj.useJQuery) {
|
||||||
|
return this.executeWithJQuery(obj);
|
||||||
|
} else {
|
||||||
|
return this.executeWithShred(obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.executeWithShred = function(obj) {
|
||||||
|
var cb, res,
|
||||||
|
_this = this;
|
||||||
|
if (!this.Shred) {
|
||||||
|
this.initShred();
|
||||||
|
}
|
||||||
|
cb = obj.on;
|
||||||
|
res = {
|
||||||
|
error: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.error(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
redirect: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.redirect(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
307: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.redirect(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
response: function(raw) {
|
||||||
|
var headers, out;
|
||||||
|
if (obj) {
|
||||||
|
headers = raw._headers;
|
||||||
|
out = {
|
||||||
|
headers: headers,
|
||||||
|
url: raw.request.url,
|
||||||
|
method: raw.request.method,
|
||||||
|
status: raw.status,
|
||||||
|
data: raw.content.data
|
||||||
|
};
|
||||||
|
return cb.response(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (obj) {
|
||||||
|
obj.on = res;
|
||||||
|
}
|
||||||
return this.shred.request(obj);
|
return this.shred.request(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.executeWithJQuery = function(obj) {
|
||||||
|
var beforeSend, cb, request,
|
||||||
|
_this = this;
|
||||||
|
cb = obj.on;
|
||||||
|
request = obj;
|
||||||
|
obj.type = obj.method;
|
||||||
|
obj.cache = false;
|
||||||
|
beforeSend = function(xhr) {
|
||||||
|
var key, _results;
|
||||||
|
if (obj.headers) {
|
||||||
|
_results = [];
|
||||||
|
for (key in obj.headers) {
|
||||||
|
if (key.toLowerCase() === "content-type") {
|
||||||
|
_results.push(obj.contentType = obj.headers[key]);
|
||||||
|
} else if (key.toLowerCase() === "accept") {
|
||||||
|
_results.push(obj.accepts = obj.headers[key]);
|
||||||
|
} else {
|
||||||
|
_results.push(xhr.setRequestHeader(key, obj.headers[key]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
obj.beforeSend = beforeSend;
|
||||||
|
obj.data = obj.body;
|
||||||
|
obj.complete = function(response, textStatus, opts) {
|
||||||
|
var headerArray, headers, i, out, _i, _j, _k, _ref, _ref1, _ref2, _ref3, _results, _results1;
|
||||||
|
headers = {};
|
||||||
|
headerArray = response.getAllResponseHeaders().split(":");
|
||||||
|
for (i = _i = 0, _ref = headerArray.length / 2, _ref1 = 2.; _ref1 > 0 ? _i <= _ref : _i >= _ref; i = _i += _ref1) {
|
||||||
|
headers[headerArray[i]] = headerArray[i + 1];
|
||||||
|
}
|
||||||
|
out = {
|
||||||
|
headers: headers,
|
||||||
|
url: request.url,
|
||||||
|
method: request.method,
|
||||||
|
status: response.status,
|
||||||
|
data: response.responseText,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
if (_ref2 = response.status, __indexOf.call((function() {
|
||||||
|
_results = [];
|
||||||
|
for (_j = 200; _j <= 299; _j++){ _results.push(_j); }
|
||||||
|
return _results;
|
||||||
|
}).apply(this), _ref2) >= 0) {
|
||||||
|
cb.response(out);
|
||||||
|
}
|
||||||
|
if ((_ref3 = response.status, __indexOf.call((function() {
|
||||||
|
_results1 = [];
|
||||||
|
for (_k = 400; _k <= 599; _k++){ _results1.push(_k); }
|
||||||
|
return _results1;
|
||||||
|
}).apply(this), _ref3) >= 0) || response.status === 0) {
|
||||||
|
cb.error(out);
|
||||||
|
}
|
||||||
|
return cb.response(out);
|
||||||
|
};
|
||||||
|
$.support.cors = true;
|
||||||
|
return $.ajax(obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.isIE = function() {
|
||||||
|
var isIE, nav, version;
|
||||||
|
({
|
||||||
|
isIE: false
|
||||||
|
});
|
||||||
|
if (typeof navigator !== 'undefined' && navigator.userAgent) {
|
||||||
|
nav = navigator.userAgent.toLowerCase();
|
||||||
|
if (nav.indexOf('msie') !== -1) {
|
||||||
|
version = parseInt(nav.split('msie')[1]);
|
||||||
|
if (version <= 8) {
|
||||||
|
isIE = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isIE;
|
||||||
|
};
|
||||||
|
|
||||||
return SwaggerHttp;
|
return SwaggerHttp;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -1286,6 +1420,8 @@
|
|||||||
|
|
||||||
this.PasswordAuthorization = PasswordAuthorization;
|
this.PasswordAuthorization = PasswordAuthorization;
|
||||||
|
|
||||||
|
this.SwaggerHttp = SwaggerHttp;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
29
dist/swagger-ui.js
vendored
29
dist/swagger-ui.js
vendored
@@ -1282,7 +1282,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
|
|
||||||
SwaggerUi.prototype.buildUrl = function(base, url) {
|
SwaggerUi.prototype.buildUrl = function(base, url) {
|
||||||
var parts;
|
var parts;
|
||||||
console.log("base is " + base);
|
log("base is " + base);
|
||||||
parts = base.split("/");
|
parts = base.split("/");
|
||||||
base = parts[0] + "//" + parts[2];
|
base = parts[0] + "//" + parts[2];
|
||||||
if (url.indexOf("/") === 0) {
|
if (url.indexOf("/") === 0) {
|
||||||
@@ -1435,7 +1435,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
|
|
||||||
ResourceView.prototype.render = function() {
|
ResourceView.prototype.render = function() {
|
||||||
var operation, _i, _len, _ref4;
|
var operation, _i, _len, _ref4;
|
||||||
console.log(this.model.description);
|
|
||||||
$(this.el).html(Handlebars.templates.resource(this.model));
|
$(this.el).html(Handlebars.templates.resource(this.model));
|
||||||
this.number = 0;
|
this.number = 0;
|
||||||
_ref4 = this.model.operationsArray;
|
_ref4 = this.model.operationsArray;
|
||||||
@@ -1513,7 +1512,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
type = param.type || param.dataType;
|
type = param.type || param.dataType;
|
||||||
if (type.toLowerCase() === 'file') {
|
if (type.toLowerCase() === 'file') {
|
||||||
if (!contentTypeModel.consumes) {
|
if (!contentTypeModel.consumes) {
|
||||||
console.log("set content type ");
|
log("set content type ");
|
||||||
contentTypeModel.consumes = 'multipart/form-data';
|
contentTypeModel.consumes = 'multipart/form-data';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1624,7 +1623,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
OperationView.prototype.handleFileUpload = function(map, form) {
|
OperationView.prototype.handleFileUpload = function(map, form) {
|
||||||
var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
|
var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
|
||||||
_this = this;
|
_this = this;
|
||||||
console.log("it's a file upload");
|
log("it's a file upload");
|
||||||
_ref5 = form.serializeArray();
|
_ref5 = form.serializeArray();
|
||||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||||
o = _ref5[_i];
|
o = _ref5[_i];
|
||||||
@@ -1648,13 +1647,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
headerParams[param.name] = map[param.name];
|
headerParams[param.name] = map[param.name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(headerParams);
|
log(headerParams);
|
||||||
_ref8 = form.find('input[type~="file"]');
|
_ref8 = form.find('input[type~="file"]');
|
||||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||||
el = _ref8[_l];
|
el = _ref8[_l];
|
||||||
bodyParam.append($(el).attr('name'), el.files[0]);
|
bodyParam.append($(el).attr('name'), el.files[0]);
|
||||||
}
|
}
|
||||||
console.log(bodyParam);
|
log(bodyParam);
|
||||||
this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
|
this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true);
|
||||||
$(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>");
|
$(".request_url", $(this.el)).html("<pre>" + this.invocationUrl + "</pre>");
|
||||||
obj = {
|
obj = {
|
||||||
@@ -1690,7 +1689,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
o.content.data = data.responseText;
|
o.content.data = data.responseText;
|
||||||
o.getHeaders = function() {
|
o.getHeaders = function() {
|
||||||
return {
|
return {
|
||||||
"Content-Type": data.getResponseHeader("Content-Type")
|
"Content-Type": data.headers("Content-Type")
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
o.request = {};
|
o.request = {};
|
||||||
@@ -1815,16 +1814,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
return formatted;
|
return formatted;
|
||||||
};
|
};
|
||||||
|
|
||||||
OperationView.prototype.showStatus = function(data) {
|
OperationView.prototype.showStatus = function(response) {
|
||||||
var code, content, contentType, headers, pre, response_body;
|
var code, content, contentType, headers, pre, response_body;
|
||||||
content = data.content.data;
|
content = response.data;
|
||||||
headers = data.getHeaders();
|
headers = response.headers;
|
||||||
contentType = headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
|
contentType = headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
|
||||||
if (!content) {
|
if (!content) {
|
||||||
code = $('<code />').text("no content");
|
code = $('<code />').text("no content");
|
||||||
pre = $('<pre class="json" />').append(code);
|
pre = $('<pre class="json" />').append(code);
|
||||||
} else if (contentType === "application/json" || /\+json$/.test(contentType)) {
|
} else if (contentType === "application/json" || /\+json$/.test(contentType)) {
|
||||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
|
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "));
|
||||||
pre = $('<pre class="json" />').append(code);
|
pre = $('<pre class="json" />').append(code);
|
||||||
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
|
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
|
||||||
code = $('<code />').text(this.formatXml(content));
|
code = $('<code />').text(this.formatXml(content));
|
||||||
@@ -1833,16 +1832,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
|||||||
code = $('<code />').html(content);
|
code = $('<code />').html(content);
|
||||||
pre = $('<pre class="xml" />').append(code);
|
pre = $('<pre class="xml" />').append(code);
|
||||||
} else if (/^image\//.test(contentType)) {
|
} else if (/^image\//.test(contentType)) {
|
||||||
pre = $('<img>').attr('src', data.request.url);
|
pre = $('<img>').attr('src', response.url);
|
||||||
} else {
|
} else {
|
||||||
code = $('<code />').text(content);
|
code = $('<code />').text(content);
|
||||||
pre = $('<pre class="json" />').append(code);
|
pre = $('<pre class="json" />').append(code);
|
||||||
}
|
}
|
||||||
response_body = pre;
|
response_body = pre;
|
||||||
$(".request_url", $(this.el)).html("<pre>" + data.request.url + "</pre>");
|
$(".request_url", $(this.el)).html("<pre>" + response.url + "</pre>");
|
||||||
$(".response_code", $(this.el)).html("<pre>" + data.status + "</pre>");
|
$(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
|
||||||
$(".response_body", $(this.el)).html(response_body);
|
$(".response_body", $(this.el)).html(response_body);
|
||||||
$(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(data.getHeaders(), null, " ").replace(/\n/g, "<br>") + "</pre>");
|
$(".response_headers", $(this.el)).html("<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>");
|
||||||
$(".response", $(this.el)).slideDown();
|
$(".response", $(this.el)).slideDown();
|
||||||
$(".response_hider", $(this.el)).show();
|
$(".response_hider", $(this.el)).show();
|
||||||
$(".response_throbber", $(this.el)).hide();
|
$(".response_throbber", $(this.el)).hide();
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
202
lib/swagger.js
202
lib/swagger.js
@@ -1,7 +1,8 @@
|
|||||||
// Generated by CoffeeScript 1.6.3
|
// Generated by CoffeeScript 1.6.3
|
||||||
(function() {
|
(function() {
|
||||||
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
__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; };
|
||||||
|
|
||||||
SwaggerApi = (function() {
|
SwaggerApi = (function() {
|
||||||
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";
|
||||||
@@ -16,6 +17,8 @@
|
|||||||
|
|
||||||
SwaggerApi.prototype.info = null;
|
SwaggerApi.prototype.info = null;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.useJQuery = null;
|
||||||
|
|
||||||
function SwaggerApi(url, options) {
|
function SwaggerApi(url, options) {
|
||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = {};
|
options = {};
|
||||||
@@ -47,6 +50,7 @@
|
|||||||
_this = this;
|
_this = this;
|
||||||
this.progress('fetching resource list: ' + this.url);
|
this.progress('fetching resource list: ' + this.url);
|
||||||
obj = {
|
obj = {
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
headers: {},
|
headers: {},
|
||||||
@@ -62,14 +66,14 @@
|
|||||||
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
response: function(rawResponse) {
|
response: function(response) {
|
||||||
var response;
|
var responseObj;
|
||||||
response = JSON.parse(rawResponse.content.data);
|
responseObj = JSON.parse(response.data);
|
||||||
_this.swaggerVersion = response.swaggerVersion;
|
_this.swaggerVersion = responseObj.swaggerVersion;
|
||||||
if (_this.swaggerVersion === "1.2") {
|
if (_this.swaggerVersion === "1.2") {
|
||||||
return _this.buildFromSpec(response);
|
return _this.buildFromSpec(responseObj);
|
||||||
} else {
|
} else {
|
||||||
return _this.buildFrom1_1Spec(response);
|
return _this.buildFrom1_1Spec(responseObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,7 +143,7 @@
|
|||||||
|
|
||||||
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
SwaggerApi.prototype.buildFrom1_1Spec = function(response) {
|
||||||
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||||
console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info");
|
||||||
if (response.apiVersion != null) {
|
if (response.apiVersion != null) {
|
||||||
this.apiVersion = response.apiVersion;
|
this.apiVersion = response.apiVersion;
|
||||||
}
|
}
|
||||||
@@ -241,15 +245,15 @@
|
|||||||
_ref = this.apis;
|
_ref = this.apis;
|
||||||
for (resource_name in _ref) {
|
for (resource_name in _ref) {
|
||||||
resource = _ref[resource_name];
|
resource = _ref[resource_name];
|
||||||
console.log(resource_name);
|
log(resource_name);
|
||||||
_ref1 = resource.operations;
|
_ref1 = resource.operations;
|
||||||
for (operation_name in _ref1) {
|
for (operation_name in _ref1) {
|
||||||
operation = _ref1[operation_name];
|
operation = _ref1[operation_name];
|
||||||
console.log(" " + operation.nickname);
|
log(" " + operation.nickname);
|
||||||
_ref2 = operation.parameters;
|
_ref2 = operation.parameters;
|
||||||
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
parameter = _ref2[_i];
|
parameter = _ref2[_i];
|
||||||
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,6 +287,7 @@
|
|||||||
this.operationsArray = [];
|
this.operationsArray = [];
|
||||||
this.modelsArray = [];
|
this.modelsArray = [];
|
||||||
this.models = {};
|
this.models = {};
|
||||||
|
this.rawModels = {};
|
||||||
if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
|
if ((resourceObj.apis != null) && (this.api.resourcePath != null)) {
|
||||||
this.addApiDeclaration(resourceObj);
|
this.addApiDeclaration(resourceObj);
|
||||||
} else {
|
} else {
|
||||||
@@ -298,15 +303,16 @@
|
|||||||
obj = {
|
obj = {
|
||||||
url: this.url,
|
url: this.url,
|
||||||
method: "get",
|
method: "get",
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
headers: {},
|
headers: {},
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
|
||||||
},
|
},
|
||||||
response: function(rawResponse) {
|
response: function(response) {
|
||||||
var response;
|
var responseObj;
|
||||||
response = JSON.parse(rawResponse.content.data);
|
responseObj = JSON.parse(response.data);
|
||||||
return _this.addApiDeclaration(response);
|
return _this.addApiDeclaration(responseObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -372,6 +378,7 @@
|
|||||||
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
swaggerModel = new SwaggerModel(modelName, models[modelName]);
|
||||||
this.modelsArray.push(swaggerModel);
|
this.modelsArray.push(swaggerModel);
|
||||||
this.models[modelName] = swaggerModel;
|
this.models[modelName] = swaggerModel;
|
||||||
|
this.rawModels[modelName] = models[modelName];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ref = this.modelsArray;
|
_ref = this.modelsArray;
|
||||||
@@ -522,7 +529,7 @@
|
|||||||
_ref1 = this.properties;
|
_ref1 = this.properties;
|
||||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
prop = _ref1[_j];
|
prop = _ref1[_j];
|
||||||
if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
|
if ((prop.refModel != null) && (modelsToIgnore[prop.refModel] !== 'undefined') === -1) {
|
||||||
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -581,7 +588,7 @@
|
|||||||
|
|
||||||
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||||
var result;
|
var result;
|
||||||
if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
|
if ((this.refModel != null) && (modelsToIgnore[this.refModel.name] === 'undefined')) {
|
||||||
result = this.refModel.createJSONSample(modelsToIgnore);
|
result = this.refModel.createJSONSample(modelsToIgnore);
|
||||||
} else {
|
} else {
|
||||||
if (this.isCollection) {
|
if (this.isCollection) {
|
||||||
@@ -661,7 +668,7 @@
|
|||||||
parameter = _ref1[_i];
|
parameter = _ref1[_i];
|
||||||
parameter.name = parameter.name || parameter.type || parameter.dataType;
|
parameter.name = parameter.name || parameter.type || parameter.dataType;
|
||||||
type = parameter.type || parameter.dataType;
|
type = parameter.type || parameter.dataType;
|
||||||
if (typeof type !== 'undefined' && type.toLowerCase() === 'boolean') {
|
if (type.toLowerCase() === 'boolean') {
|
||||||
parameter.allowableValues = {};
|
parameter.allowableValues = {};
|
||||||
parameter.allowableValues.values = ["true", "false"];
|
parameter.allowableValues.values = ["true", "false"];
|
||||||
}
|
}
|
||||||
@@ -776,19 +783,19 @@
|
|||||||
}
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
error = function(xhr, textStatus, error) {
|
error = function(xhr, textStatus, error) {
|
||||||
return console.log(xhr, textStatus, error);
|
return log(xhr, textStatus, error);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function(data) {
|
callback = function(response) {
|
||||||
var content;
|
var content;
|
||||||
content = null;
|
content = null;
|
||||||
if (data.content != null) {
|
if (response != null) {
|
||||||
content = data.content.data;
|
content = response.data;
|
||||||
} else {
|
} else {
|
||||||
content = "no data";
|
content = "no data";
|
||||||
}
|
}
|
||||||
return console.log("default callback: " + content);
|
return log("default callback: " + content);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
params = {};
|
params = {};
|
||||||
@@ -990,7 +997,7 @@
|
|||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
param = _ref[_i];
|
param = _ref[_i];
|
||||||
if (typeof type !== 'undefined' && type.toLowerCase() === "file") {
|
if (type.toLowerCase() === "file") {
|
||||||
_results.push(param);
|
_results.push(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1005,8 +1012,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && this.operation.consumes) {
|
if (requestContentType && this.operation.consumes) {
|
||||||
if (this.operation.consumes.indexOf(requestContentType) === -1) {
|
if (this.operation.consumes[requestContentType] === 'undefined') {
|
||||||
console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
|
log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||||
if (this.requestContentType === null) {
|
if (this.requestContentType === null) {
|
||||||
requestContentType = this.operation.consumes[0];
|
requestContentType = this.operation.consumes[0];
|
||||||
}
|
}
|
||||||
@@ -1023,8 +1030,8 @@
|
|||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
}
|
}
|
||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces[responseContentType] === 'undefined') {
|
||||||
console.log("server can't produce " + responseContentType);
|
log("server can't produce " + responseContentType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||||
@@ -1073,6 +1080,7 @@
|
|||||||
method: this.type,
|
method: this.type,
|
||||||
headers: myHeaders,
|
headers: myHeaders,
|
||||||
body: body,
|
body: body,
|
||||||
|
useJQuery: this.useJQuery,
|
||||||
on: {
|
on: {
|
||||||
error: function(response) {
|
error: function(response) {
|
||||||
return _this.errorCallback(response, _this.opts.parent);
|
return _this.errorCallback(response, _this.opts.parent);
|
||||||
@@ -1102,7 +1110,6 @@
|
|||||||
obj.canceled = true;
|
obj.canceled = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log(obj);
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1128,13 +1135,15 @@
|
|||||||
})();
|
})();
|
||||||
|
|
||||||
SwaggerHttp = (function() {
|
SwaggerHttp = (function() {
|
||||||
|
function SwaggerHttp() {}
|
||||||
|
|
||||||
SwaggerHttp.prototype.Shred = null;
|
SwaggerHttp.prototype.Shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.shred = null;
|
SwaggerHttp.prototype.shred = null;
|
||||||
|
|
||||||
SwaggerHttp.prototype.content = null;
|
SwaggerHttp.prototype.content = null;
|
||||||
|
|
||||||
function SwaggerHttp() {
|
SwaggerHttp.prototype.initShred = function() {
|
||||||
var identity, toString,
|
var identity, toString,
|
||||||
_this = this;
|
_this = this;
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
@@ -1151,22 +1160,147 @@
|
|||||||
};
|
};
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== 'undefined') {
|
||||||
this.content = require("./shred/content");
|
this.content = require("./shred/content");
|
||||||
this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
return this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
parser: identity,
|
parser: identity,
|
||||||
stringify: toString
|
stringify: toString
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
return this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], {
|
||||||
parser: identity,
|
parser: identity,
|
||||||
stringify: toString
|
stringify: toString
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
SwaggerHttp.prototype.execute = function(obj) {
|
SwaggerHttp.prototype.execute = function(obj) {
|
||||||
|
if (this.isIE() || obj.useJQuery) {
|
||||||
|
return this.executeWithJQuery(obj);
|
||||||
|
} else {
|
||||||
|
return this.executeWithShred(obj);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.executeWithShred = function(obj) {
|
||||||
|
var cb, res,
|
||||||
|
_this = this;
|
||||||
|
if (!this.Shred) {
|
||||||
|
this.initShred();
|
||||||
|
}
|
||||||
|
cb = obj.on;
|
||||||
|
res = {
|
||||||
|
error: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.error(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
redirect: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.redirect(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
307: function(response) {
|
||||||
|
if (obj) {
|
||||||
|
return cb.redirect(response);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
response: function(raw) {
|
||||||
|
var headers, out;
|
||||||
|
if (obj) {
|
||||||
|
headers = raw._headers;
|
||||||
|
out = {
|
||||||
|
headers: headers,
|
||||||
|
url: raw.request.url,
|
||||||
|
method: raw.request.method,
|
||||||
|
status: raw.status,
|
||||||
|
data: raw.content.data
|
||||||
|
};
|
||||||
|
return cb.response(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (obj) {
|
||||||
|
obj.on = res;
|
||||||
|
}
|
||||||
return this.shred.request(obj);
|
return this.shred.request(obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.executeWithJQuery = function(obj) {
|
||||||
|
var beforeSend, cb, request,
|
||||||
|
_this = this;
|
||||||
|
cb = obj.on;
|
||||||
|
request = obj;
|
||||||
|
obj.type = obj.method;
|
||||||
|
obj.cache = false;
|
||||||
|
beforeSend = function(xhr) {
|
||||||
|
var key, _results;
|
||||||
|
if (obj.headers) {
|
||||||
|
_results = [];
|
||||||
|
for (key in obj.headers) {
|
||||||
|
if (key.toLowerCase() === "content-type") {
|
||||||
|
_results.push(obj.contentType = obj.headers[key]);
|
||||||
|
} else if (key.toLowerCase() === "accept") {
|
||||||
|
_results.push(obj.accepts = obj.headers[key]);
|
||||||
|
} else {
|
||||||
|
_results.push(xhr.setRequestHeader(key, obj.headers[key]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
obj.beforeSend = beforeSend;
|
||||||
|
obj.data = obj.body;
|
||||||
|
obj.complete = function(response, textStatus, opts) {
|
||||||
|
var headerArray, headers, i, out, _i, _j, _k, _ref, _ref1, _ref2, _ref3, _results, _results1;
|
||||||
|
headers = {};
|
||||||
|
headerArray = response.getAllResponseHeaders().split(":");
|
||||||
|
for (i = _i = 0, _ref = headerArray.length / 2, _ref1 = 2.; _ref1 > 0 ? _i <= _ref : _i >= _ref; i = _i += _ref1) {
|
||||||
|
headers[headerArray[i]] = headerArray[i + 1];
|
||||||
|
}
|
||||||
|
out = {
|
||||||
|
headers: headers,
|
||||||
|
url: request.url,
|
||||||
|
method: request.method,
|
||||||
|
status: response.status,
|
||||||
|
data: response.responseText,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
if (_ref2 = response.status, __indexOf.call((function() {
|
||||||
|
_results = [];
|
||||||
|
for (_j = 200; _j <= 299; _j++){ _results.push(_j); }
|
||||||
|
return _results;
|
||||||
|
}).apply(this), _ref2) >= 0) {
|
||||||
|
cb.response(out);
|
||||||
|
}
|
||||||
|
if ((_ref3 = response.status, __indexOf.call((function() {
|
||||||
|
_results1 = [];
|
||||||
|
for (_k = 400; _k <= 599; _k++){ _results1.push(_k); }
|
||||||
|
return _results1;
|
||||||
|
}).apply(this), _ref3) >= 0) || response.status === 0) {
|
||||||
|
cb.error(out);
|
||||||
|
}
|
||||||
|
return cb.response(out);
|
||||||
|
};
|
||||||
|
$.support.cors = true;
|
||||||
|
return $.ajax(obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerHttp.prototype.isIE = function() {
|
||||||
|
var isIE, nav, version;
|
||||||
|
({
|
||||||
|
isIE: false
|
||||||
|
});
|
||||||
|
if (typeof navigator !== 'undefined' && navigator.userAgent) {
|
||||||
|
nav = navigator.userAgent.toLowerCase();
|
||||||
|
if (nav.indexOf('msie') !== -1) {
|
||||||
|
version = parseInt(nav.split('msie')[1]);
|
||||||
|
if (version <= 8) {
|
||||||
|
isIE = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isIE;
|
||||||
|
};
|
||||||
|
|
||||||
return SwaggerHttp;
|
return SwaggerHttp;
|
||||||
|
|
||||||
})();
|
})();
|
||||||
@@ -1286,6 +1420,8 @@
|
|||||||
|
|
||||||
this.PasswordAuthorization = PasswordAuthorization;
|
this.PasswordAuthorization = PasswordAuthorization;
|
||||||
|
|
||||||
|
this.SwaggerHttp = SwaggerHttp;
|
||||||
|
|
||||||
this.authorizations = new SwaggerAuthorizations();
|
this.authorizations = new SwaggerAuthorizations();
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
"readmeFilename": "README.md",
|
"readmeFilename": "README.md",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"coffee-script": "~1.5.0",
|
"coffee-script": "~1.5.0",
|
||||||
"swagger-client": "2.0.8",
|
"swagger-client": "2.0.9",
|
||||||
"handlebars": "~1.0.10",
|
"handlebars": "~1.0.10",
|
||||||
"less": "~1.4.2"
|
"less": "~1.4.2"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ class SwaggerUi extends Backbone.Router
|
|||||||
)
|
)
|
||||||
|
|
||||||
buildUrl: (base, url) ->
|
buildUrl: (base, url) ->
|
||||||
console.log "base is " + base
|
log "base is " + base
|
||||||
parts = base.split("/")
|
parts = base.split("/")
|
||||||
base = parts[0] + "//" + parts[2]
|
base = parts[0] + "//" + parts[2]
|
||||||
if url.indexOf("/") is 0
|
if url.indexOf("/") is 0
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class OperationView extends Backbone.View
|
|||||||
type = param.type || param.dataType
|
type = param.type || param.dataType
|
||||||
if type.toLowerCase() == 'file'
|
if type.toLowerCase() == 'file'
|
||||||
if !contentTypeModel.consumes
|
if !contentTypeModel.consumes
|
||||||
console.log "set content type "
|
log "set content type "
|
||||||
contentTypeModel.consumes = 'multipart/form-data'
|
contentTypeModel.consumes = 'multipart/form-data'
|
||||||
|
|
||||||
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
|
||||||
@@ -110,7 +110,7 @@ class OperationView extends Backbone.View
|
|||||||
parent.showCompleteStatus response
|
parent.showCompleteStatus response
|
||||||
|
|
||||||
handleFileUpload: (map, form) ->
|
handleFileUpload: (map, form) ->
|
||||||
console.log "it's a file upload"
|
log "it's a file upload"
|
||||||
for o in form.serializeArray()
|
for o in form.serializeArray()
|
||||||
if(o.value? && jQuery.trim(o.value).length > 0)
|
if(o.value? && jQuery.trim(o.value).length > 0)
|
||||||
map[o.name] = o.value
|
map[o.name] = o.value
|
||||||
@@ -129,13 +129,13 @@ class OperationView extends Backbone.View
|
|||||||
if param.paramType is 'header'
|
if param.paramType is 'header'
|
||||||
headerParams[param.name] = map[param.name]
|
headerParams[param.name] = map[param.name]
|
||||||
|
|
||||||
console.log headerParams
|
log headerParams
|
||||||
|
|
||||||
# add files
|
# add files
|
||||||
for el in form.find('input[type~="file"]')
|
for el in form.find('input[type~="file"]')
|
||||||
bodyParam.append($(el).attr('name'), el.files[0])
|
bodyParam.append($(el).attr('name'), el.files[0])
|
||||||
|
|
||||||
console.log(bodyParam)
|
log(bodyParam)
|
||||||
|
|
||||||
@invocationUrl =
|
@invocationUrl =
|
||||||
if @model.supportHeaderParams()
|
if @model.supportHeaderParams()
|
||||||
@@ -174,7 +174,7 @@ class OperationView extends Backbone.View
|
|||||||
o = {}
|
o = {}
|
||||||
o.content = {}
|
o.content = {}
|
||||||
o.content.data = data.responseText
|
o.content.data = data.responseText
|
||||||
o.getHeaders = () => {"Content-Type": data.getResponseHeader("Content-Type")}
|
o.getHeaders = () => {"Content-Type": data.headers("Content-Type")}
|
||||||
o.request = {}
|
o.request = {}
|
||||||
o.request.url = @invocationUrl
|
o.request.url = @invocationUrl
|
||||||
o.status = data.status
|
o.status = data.status
|
||||||
@@ -271,9 +271,9 @@ class OperationView extends Backbone.View
|
|||||||
|
|
||||||
|
|
||||||
# puts the response data in UI
|
# puts the response data in UI
|
||||||
showStatus: (data) ->
|
showStatus: (response) ->
|
||||||
content = data.content.data
|
content = response.data
|
||||||
headers = data.getHeaders()
|
headers = response.headers
|
||||||
|
|
||||||
# if server is nice, and sends content-type back, we can use it
|
# 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["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
|
||||||
@@ -282,7 +282,7 @@ class OperationView extends Backbone.View
|
|||||||
code = $('<code />').text("no content")
|
code = $('<code />').text("no content")
|
||||||
pre = $('<pre class="json" />').append(code)
|
pre = $('<pre class="json" />').append(code)
|
||||||
else if contentType is "application/json" || /\+json$/.test(contentType)
|
else if contentType is "application/json" || /\+json$/.test(contentType)
|
||||||
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
|
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "))
|
||||||
pre = $('<pre class="json" />').append(code)
|
pre = $('<pre class="json" />').append(code)
|
||||||
else if contentType is "application/xml" || /\+xml$/.test(contentType)
|
else if contentType is "application/xml" || /\+xml$/.test(contentType)
|
||||||
code = $('<code />').text(@formatXml(content))
|
code = $('<code />').text(@formatXml(content))
|
||||||
@@ -291,17 +291,17 @@ class OperationView extends Backbone.View
|
|||||||
code = $('<code />').html(content)
|
code = $('<code />').html(content)
|
||||||
pre = $('<pre class="xml" />').append(code)
|
pre = $('<pre class="xml" />').append(code)
|
||||||
else if /^image\//.test(contentType)
|
else if /^image\//.test(contentType)
|
||||||
pre = $('<img>').attr('src',data.request.url)
|
pre = $('<img>').attr('src',response.url)
|
||||||
else
|
else
|
||||||
# don't know what to render!
|
# don't know what to render!
|
||||||
code = $('<code />').text(content)
|
code = $('<code />').text(content)
|
||||||
pre = $('<pre class="json" />').append(code)
|
pre = $('<pre class="json" />').append(code)
|
||||||
|
|
||||||
response_body = pre
|
response_body = pre
|
||||||
$(".request_url", $(@el)).html "<pre>" + data.request.url + "</pre>"
|
$(".request_url", $(@el)).html "<pre>" + response.url + "</pre>"
|
||||||
$(".response_code", $(@el)).html "<pre>" + data.status + "</pre>"
|
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
|
||||||
$(".response_body", $(@el)).html response_body
|
$(".response_body", $(@el)).html response_body
|
||||||
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(data.getHeaders(), null, " ").replace(/\n/g, "<br>") + "</pre>"
|
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
|
||||||
$(".response", $(@el)).slideDown()
|
$(".response", $(@el)).slideDown()
|
||||||
$(".response_hider", $(@el)).show()
|
$(".response_hider", $(@el)).show()
|
||||||
$(".response_throbber", $(@el)).hide()
|
$(".response_throbber", $(@el)).hide()
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ class ResourceView extends Backbone.View
|
|||||||
initialize: ->
|
initialize: ->
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
console.log @model.description
|
|
||||||
$(@el).html(Handlebars.templates.resource(@model))
|
$(@el).html(Handlebars.templates.resource(@model))
|
||||||
|
|
||||||
@number = 0
|
@number = 0
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Swagger UI</title>
|
<title>Swagger UI</title>
|
||||||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/highlight.default.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/>
|
||||||
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
<script type="text/javascript" src="lib/shred.bundle.js"></script>
|
||||||
@@ -23,25 +23,20 @@
|
|||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
if(console) {
|
log("Loaded SwaggerUI")
|
||||||
console.log("Loaded SwaggerUI")
|
|
||||||
}
|
|
||||||
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
$('pre code').each(function(i, e) {hljs.highlightBlock(e)});
|
||||||
},
|
},
|
||||||
onFailure: function(data) {
|
onFailure: function(data) {
|
||||||
if(console) {
|
log("Unable to Load SwaggerUI");
|
||||||
console.log("Unable to Load SwaggerUI");
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
docExpansion: "none"
|
docExpansion: "none"
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#input_apiKey').change(function() {
|
$('#input_apiKey').change(function() {
|
||||||
var key = $('#input_apiKey')[0].value;
|
var key = $('#input_apiKey')[0].value;
|
||||||
console.log("key: " + key);
|
log("key: " + key);
|
||||||
if(key && key.trim() != "") {
|
if(key && key.trim() != "") {
|
||||||
console.log("added key " + key);
|
log("added key " + key);
|
||||||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user