updated swagger.js version
This commit is contained in:
149
dist/lib/swagger.js
vendored
149
dist/lib/swagger.js
vendored
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.26
|
||||
// version 2.0.29
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -25,13 +25,13 @@ if (!Array.prototype.indexOf) {
|
||||
}
|
||||
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
|
||||
if (!('map' in Array.prototype)) {
|
||||
@@ -562,15 +562,20 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
||||
};
|
||||
|
||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
if(sampleModels[this.name]) {
|
||||
return sampleModels[this.name];
|
||||
}
|
||||
else {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
var SwaggerModelProperty = function(name, obj) {
|
||||
@@ -793,7 +798,22 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
||||
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
if (val) {
|
||||
val = listType ? [val] : val;
|
||||
return JSON.stringify(val, null, 2);
|
||||
if(typeof val == "string")
|
||||
return val;
|
||||
else if(typeof val === "object") {
|
||||
var t = val;
|
||||
if(val instanceof Array && val.length > 0) {
|
||||
t = val[0];
|
||||
}
|
||||
if(t.nodeName) {
|
||||
var xmlString = new XMLSerializer().serializeToString(t);
|
||||
return this.formatXml(xmlString);
|
||||
}
|
||||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -882,6 +902,21 @@ SwaggerOperation.prototype.pathXml = function() {
|
||||
return this.path.replace("{format}", "xml");
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.encodePathParam = function(pathParam) {
|
||||
var encParts, part, parts, _i, _len;
|
||||
if (pathParam.indexOf("/") === -1) {
|
||||
return encodeURIComponent(pathParam);
|
||||
} else {
|
||||
parts = pathParam.split("/");
|
||||
encParts = [];
|
||||
for (_i = 0, _len = parts.length; _i < _len; _i++) {
|
||||
part = parts[_i];
|
||||
encParts.push(encodeURIComponent(part));
|
||||
}
|
||||
return encParts.join("/");
|
||||
}
|
||||
};
|
||||
|
||||
SwaggerOperation.prototype.urlify = function(args) {
|
||||
var url = this.resource.basePath + this.pathJson();
|
||||
var params = this.parameters;
|
||||
@@ -891,7 +926,7 @@ SwaggerOperation.prototype.urlify = function(args) {
|
||||
if(args[param.name]) {
|
||||
// apply path params and remove from args
|
||||
var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi');
|
||||
url = url.replace(reg, encodeURIComponent(args[param.name]));
|
||||
url = url.replace(reg, this.encodePathParam(args[param.name]));
|
||||
delete args[param.name];
|
||||
}
|
||||
else
|
||||
@@ -960,6 +995,80 @@ SwaggerOperation.prototype.help = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
SwaggerOperation.prototype.formatXml = function(xml) {
|
||||
var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
|
||||
reg = /(>)(<)(\/*)/g;
|
||||
wsexp = /[ ]*(.*)[ ]+\n/g;
|
||||
contexp = /(<.+>)(.+\n)/g;
|
||||
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
|
||||
pad = 0;
|
||||
formatted = '';
|
||||
lines = xml.split('\n');
|
||||
indent = 0;
|
||||
lastType = 'other';
|
||||
transitions = {
|
||||
'single->single': 0,
|
||||
'single->closing': -1,
|
||||
'single->opening': 0,
|
||||
'single->other': 0,
|
||||
'closing->single': 0,
|
||||
'closing->closing': -1,
|
||||
'closing->opening': 0,
|
||||
'closing->other': 0,
|
||||
'opening->single': 1,
|
||||
'opening->closing': 0,
|
||||
'opening->opening': 1,
|
||||
'opening->other': 1,
|
||||
'other->single': 0,
|
||||
'other->closing': -1,
|
||||
'other->opening': 0,
|
||||
'other->other': 0
|
||||
};
|
||||
_fn = function(ln) {
|
||||
var fromTo, j, key, padding, type, types, value;
|
||||
types = {
|
||||
single: Boolean(ln.match(/<.+\/>/)),
|
||||
closing: Boolean(ln.match(/<\/.+>/)),
|
||||
opening: Boolean(ln.match(/<[^!?].*>/))
|
||||
};
|
||||
type = ((function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (key in types) {
|
||||
value = types[key];
|
||||
if (value) {
|
||||
_results.push(key);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})())[0];
|
||||
type = type === void 0 ? 'other' : type;
|
||||
fromTo = lastType + '->' + type;
|
||||
lastType = type;
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
})()).join('');
|
||||
if (fromTo === 'opening->closing') {
|
||||
return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
|
||||
} else {
|
||||
return formatted += padding + ln + '\n';
|
||||
}
|
||||
};
|
||||
for (_i = 0, _len = lines.length; _i < _len; _i++) {
|
||||
ln = lines[_i];
|
||||
_fn(ln);
|
||||
}
|
||||
return formatted;
|
||||
};
|
||||
|
||||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var _this = this;
|
||||
var errors = [];
|
||||
@@ -1388,6 +1497,9 @@ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
|
||||
var e = (typeof window !== 'undefined' ? window : exports);
|
||||
|
||||
var sampleModels = {};
|
||||
|
||||
e.SampleModels = sampleModels;
|
||||
e.SwaggerHttp = SwaggerHttp;
|
||||
e.SwaggerRequest = SwaggerRequest;
|
||||
e.authorizations = new SwaggerAuthorizations();
|
||||
@@ -1400,3 +1512,4 @@ e.SwaggerModel = SwaggerModel;
|
||||
e.SwaggerModelProperty = SwaggerModelProperty;
|
||||
e.SwaggerResource = SwaggerResource;
|
||||
e.SwaggerApi = SwaggerApi;
|
||||
|
||||
|
||||
156
dist/swagger-ui.js
vendored
156
dist/swagger-ui.js
vendored
@@ -1,3 +1,5 @@
|
||||
// swagger-ui.js
|
||||
// version 2.0.15
|
||||
$(function() {
|
||||
|
||||
// Helper function for vertically aligning DOM elements
|
||||
@@ -1207,18 +1209,18 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
|
||||
|
||||
|
||||
// Generated by CoffeeScript 1.5.0
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
(function() {
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi,
|
||||
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
SwaggerUi = (function(_super) {
|
||||
|
||||
__extends(SwaggerUi, _super);
|
||||
|
||||
function SwaggerUi() {
|
||||
SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
_ref = SwaggerUi.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
SwaggerUi.prototype.dom_id = "swagger_ui";
|
||||
@@ -1267,9 +1269,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
SwaggerUi.prototype.load = function() {
|
||||
var url, _ref;
|
||||
if ((_ref = this.mainView) != null) {
|
||||
_ref.clear();
|
||||
var url, _ref1;
|
||||
if ((_ref1 = this.mainView) != null) {
|
||||
_ref1.clear();
|
||||
}
|
||||
url = this.options.url;
|
||||
if (url.indexOf("http") !== 0) {
|
||||
@@ -1358,11 +1360,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
window.SwaggerUi = SwaggerUi;
|
||||
|
||||
HeaderView = (function(_super) {
|
||||
|
||||
__extends(HeaderView, _super);
|
||||
|
||||
function HeaderView() {
|
||||
HeaderView.__super__.constructor.apply(this, arguments);
|
||||
_ref1 = HeaderView.__super__.constructor.apply(this, arguments);
|
||||
return _ref1;
|
||||
}
|
||||
|
||||
HeaderView.prototype.events = {
|
||||
@@ -1420,23 +1422,23 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
MainView = (function(_super) {
|
||||
|
||||
__extends(MainView, _super);
|
||||
|
||||
function MainView() {
|
||||
MainView.__super__.constructor.apply(this, arguments);
|
||||
_ref2 = MainView.__super__.constructor.apply(this, arguments);
|
||||
return _ref2;
|
||||
}
|
||||
|
||||
MainView.prototype.initialize = function() {};
|
||||
|
||||
MainView.prototype.render = function() {
|
||||
var counter, id, resource, resources, _i, _len, _ref;
|
||||
var counter, id, resource, resources, _i, _len, _ref3;
|
||||
$(this.el).html(Handlebars.templates.main(this.model));
|
||||
resources = {};
|
||||
counter = 0;
|
||||
_ref = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
resource = _ref[_i];
|
||||
_ref3 = this.model.apisArray;
|
||||
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
|
||||
resource = _ref3[_i];
|
||||
id = resource.name;
|
||||
while (typeof resources[id] !== 'undefined') {
|
||||
id = id + "_" + counter;
|
||||
@@ -1469,22 +1471,22 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResourceView = (function(_super) {
|
||||
|
||||
__extends(ResourceView, _super);
|
||||
|
||||
function ResourceView() {
|
||||
ResourceView.__super__.constructor.apply(this, arguments);
|
||||
_ref3 = ResourceView.__super__.constructor.apply(this, arguments);
|
||||
return _ref3;
|
||||
}
|
||||
|
||||
ResourceView.prototype.initialize = function() {};
|
||||
|
||||
ResourceView.prototype.render = function() {
|
||||
var counter, id, methods, operation, _i, _len, _ref;
|
||||
var counter, id, methods, operation, _i, _len, _ref4;
|
||||
$(this.el).html(Handlebars.templates.resource(this.model));
|
||||
methods = {};
|
||||
_ref = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
operation = _ref[_i];
|
||||
_ref4 = this.model.operationsArray;
|
||||
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
|
||||
operation = _ref4[_i];
|
||||
counter = 0;
|
||||
id = operation.nickname;
|
||||
while (typeof methods[id] !== 'undefined') {
|
||||
@@ -1516,11 +1518,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
OperationView = (function(_super) {
|
||||
|
||||
__extends(OperationView, _super);
|
||||
|
||||
function OperationView() {
|
||||
OperationView.__super__.constructor.apply(this, arguments);
|
||||
_ref4 = OperationView.__super__.constructor.apply(this, arguments);
|
||||
return _ref4;
|
||||
}
|
||||
|
||||
OperationView.prototype.invocationUrl = null;
|
||||
@@ -1571,16 +1573,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.render = function() {
|
||||
var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3;
|
||||
var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8;
|
||||
isMethodSubmissionSupported = true;
|
||||
if (!isMethodSubmissionSupported) {
|
||||
this.model.isReadOnly = true;
|
||||
}
|
||||
this.model.oauth = null;
|
||||
if (this.model.authorizations) {
|
||||
_ref = this.model.authorizations;
|
||||
for (k in _ref) {
|
||||
v = _ref[k];
|
||||
_ref5 = this.model.authorizations;
|
||||
for (k in _ref5) {
|
||||
v = _ref5[k];
|
||||
if (k === "oauth2") {
|
||||
if (this.model.oauth === null) {
|
||||
this.model.oauth = {};
|
||||
@@ -1615,9 +1617,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
contentTypeModel.consumes = this.model.consumes;
|
||||
contentTypeModel.produces = this.model.produces;
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
type = param.type || param.dataType;
|
||||
if (type.toLowerCase() === 'file') {
|
||||
if (!contentTypeModel.consumes) {
|
||||
@@ -1630,14 +1632,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: contentTypeModel
|
||||
});
|
||||
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
|
||||
_ref2 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
param = _ref2[_k];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
this.addParameter(param, contentTypeModel.consumes);
|
||||
}
|
||||
_ref3 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
statusCode = _ref3[_l];
|
||||
_ref8 = this.model.responseMessages;
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
statusCode = _ref8[_l];
|
||||
this.addStatusCode(statusCode);
|
||||
}
|
||||
return this;
|
||||
@@ -1664,7 +1666,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.submitOperation = function(e) {
|
||||
var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2;
|
||||
var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7;
|
||||
if (e != null) {
|
||||
e.preventDefault();
|
||||
}
|
||||
@@ -1689,9 +1691,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
parent: this
|
||||
};
|
||||
isFileUpload = false;
|
||||
_ref = form.find("input");
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
_ref5 = form.find("input");
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
@@ -1699,16 +1701,16 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
isFileUpload = true;
|
||||
}
|
||||
}
|
||||
_ref1 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
o = _ref1[_j];
|
||||
_ref6 = form.find("textarea");
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
o = _ref6[_j];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map["body"] = o.value;
|
||||
}
|
||||
}
|
||||
_ref2 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
o = _ref2[_k];
|
||||
_ref7 = form.find("select");
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
o = _ref7[_k];
|
||||
val = this.getSelectedValue(o);
|
||||
if ((val != null) && jQuery.trim(val).length > 0) {
|
||||
map[o.name] = val;
|
||||
@@ -1730,20 +1732,20 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.handleFileUpload = function(map, form) {
|
||||
var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _ref3,
|
||||
var bodyParam, el, headerParams, o, obj, param, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8,
|
||||
_this = this;
|
||||
log("it's a file upload");
|
||||
_ref = form.serializeArray();
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
o = _ref[_i];
|
||||
_ref5 = form.serializeArray();
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
o = _ref5[_i];
|
||||
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
|
||||
map[o.name] = o.value;
|
||||
}
|
||||
}
|
||||
bodyParam = new FormData();
|
||||
_ref1 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||
param = _ref1[_j];
|
||||
_ref6 = this.model.parameters;
|
||||
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
|
||||
param = _ref6[_j];
|
||||
if (param.paramType === 'form') {
|
||||
if (map[param.name] !== void 0) {
|
||||
bodyParam.append(param.name, map[param.name]);
|
||||
@@ -1751,17 +1753,17 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
}
|
||||
}
|
||||
headerParams = {};
|
||||
_ref2 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
|
||||
param = _ref2[_k];
|
||||
_ref7 = this.model.parameters;
|
||||
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
|
||||
param = _ref7[_k];
|
||||
if (param.paramType === 'header') {
|
||||
headerParams[param.name] = map[param.name];
|
||||
}
|
||||
}
|
||||
log(headerParams);
|
||||
_ref3 = form.find('input[type~="file"]');
|
||||
for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
|
||||
el = _ref3[_l];
|
||||
_ref8 = form.find('input[type~="file"]');
|
||||
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
|
||||
el = _ref8[_l];
|
||||
bodyParam.append($(el).attr('name'), el.files[0]);
|
||||
}
|
||||
log(bodyParam);
|
||||
@@ -1814,14 +1816,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.getSelectedValue = function(select) {
|
||||
var opt, options, _i, _len, _ref;
|
||||
var opt, options, _i, _len, _ref5;
|
||||
if (!select.multiple) {
|
||||
return select.value;
|
||||
} else {
|
||||
options = [];
|
||||
_ref = select.options;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
opt = _ref[_i];
|
||||
_ref5 = select.options;
|
||||
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
|
||||
opt = _ref5[_i];
|
||||
if (opt.selected) {
|
||||
options.push(opt.value);
|
||||
}
|
||||
@@ -1909,9 +1911,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref, _results;
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
@@ -1984,11 +1986,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
StatusCodeView = (function(_super) {
|
||||
|
||||
__extends(StatusCodeView, _super);
|
||||
|
||||
function StatusCodeView() {
|
||||
StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
_ref5 = StatusCodeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref5;
|
||||
}
|
||||
|
||||
StatusCodeView.prototype.initialize = function() {};
|
||||
@@ -2009,11 +2011,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterView = (function(_super) {
|
||||
|
||||
__extends(ParameterView, _super);
|
||||
|
||||
function ParameterView() {
|
||||
ParameterView.__super__.constructor.apply(this, arguments);
|
||||
_ref6 = ParameterView.__super__.constructor.apply(this, arguments);
|
||||
return _ref6;
|
||||
}
|
||||
|
||||
ParameterView.prototype.initialize = function() {
|
||||
@@ -2098,11 +2100,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
SignatureView = (function(_super) {
|
||||
|
||||
__extends(SignatureView, _super);
|
||||
|
||||
function SignatureView() {
|
||||
SignatureView.__super__.constructor.apply(this, arguments);
|
||||
_ref7 = SignatureView.__super__.constructor.apply(this, arguments);
|
||||
return _ref7;
|
||||
}
|
||||
|
||||
SignatureView.prototype.events = {
|
||||
@@ -2167,11 +2169,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ContentTypeView, _super);
|
||||
|
||||
function ContentTypeView() {
|
||||
ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref8 = ContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref8;
|
||||
}
|
||||
|
||||
ContentTypeView.prototype.initialize = function() {};
|
||||
@@ -2193,11 +2195,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ResponseContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ResponseContentTypeView, _super);
|
||||
|
||||
function ResponseContentTypeView() {
|
||||
ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref9;
|
||||
}
|
||||
|
||||
ResponseContentTypeView.prototype.initialize = function() {};
|
||||
@@ -2219,11 +2221,11 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
})(Backbone.View);
|
||||
|
||||
ParameterContentTypeView = (function(_super) {
|
||||
|
||||
__extends(ParameterContentTypeView, _super);
|
||||
|
||||
function ParameterContentTypeView() {
|
||||
ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
_ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments);
|
||||
return _ref10;
|
||||
}
|
||||
|
||||
ParameterContentTypeView.prototype.initialize = function() {};
|
||||
|
||||
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
132
lib/swagger.js
132
lib/swagger.js
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.27
|
||||
// version 2.0.29
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -25,13 +25,13 @@ if (!Array.prototype.indexOf) {
|
||||
}
|
||||
|
||||
if (!('filter' in Array.prototype)) {
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
Array.prototype.filter= function(filter, that /*opt*/) {
|
||||
var other= [], v;
|
||||
for (var i=0, n= this.length; i<n; i++)
|
||||
if (i in this && filter.call(that, v= this[i], i, this))
|
||||
other.push(v);
|
||||
return other;
|
||||
};
|
||||
}
|
||||
|
||||
if (!('map' in Array.prototype)) {
|
||||
@@ -562,15 +562,20 @@ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
|
||||
};
|
||||
|
||||
SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
if(sampleModels[this.name]) {
|
||||
return sampleModels[this.name];
|
||||
}
|
||||
else {
|
||||
var result = {};
|
||||
var modelsToIgnore = (modelsToIgnore||[])
|
||||
modelsToIgnore.push(this.name);
|
||||
for (var i = 0; i < this.properties.length; i++) {
|
||||
prop = this.properties[i];
|
||||
result[prop.name] = prop.getSampleValue(modelsToIgnore);
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
}
|
||||
modelsToIgnore.pop(this.name);
|
||||
return result;
|
||||
};
|
||||
|
||||
var SwaggerModelProperty = function(name, obj) {
|
||||
@@ -793,7 +798,22 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) {
|
||||
val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample());
|
||||
if (val) {
|
||||
val = listType ? [val] : val;
|
||||
return JSON.stringify(val, null, 2);
|
||||
if(typeof val == "string")
|
||||
return val;
|
||||
else if(typeof val === "object") {
|
||||
var t = val;
|
||||
if(val instanceof Array && val.length > 0) {
|
||||
t = val[0];
|
||||
}
|
||||
if(t.nodeName) {
|
||||
var xmlString = new XMLSerializer().serializeToString(t);
|
||||
return this.formatXml(xmlString);
|
||||
}
|
||||
else
|
||||
return JSON.stringify(val, null, 2);
|
||||
}
|
||||
else
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -975,6 +995,80 @@ SwaggerOperation.prototype.help = function() {
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
SwaggerOperation.prototype.formatXml = function(xml) {
|
||||
var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len;
|
||||
reg = /(>)(<)(\/*)/g;
|
||||
wsexp = /[ ]*(.*)[ ]+\n/g;
|
||||
contexp = /(<.+>)(.+\n)/g;
|
||||
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
|
||||
pad = 0;
|
||||
formatted = '';
|
||||
lines = xml.split('\n');
|
||||
indent = 0;
|
||||
lastType = 'other';
|
||||
transitions = {
|
||||
'single->single': 0,
|
||||
'single->closing': -1,
|
||||
'single->opening': 0,
|
||||
'single->other': 0,
|
||||
'closing->single': 0,
|
||||
'closing->closing': -1,
|
||||
'closing->opening': 0,
|
||||
'closing->other': 0,
|
||||
'opening->single': 1,
|
||||
'opening->closing': 0,
|
||||
'opening->opening': 1,
|
||||
'opening->other': 1,
|
||||
'other->single': 0,
|
||||
'other->closing': -1,
|
||||
'other->opening': 0,
|
||||
'other->other': 0
|
||||
};
|
||||
_fn = function(ln) {
|
||||
var fromTo, j, key, padding, type, types, value;
|
||||
types = {
|
||||
single: Boolean(ln.match(/<.+\/>/)),
|
||||
closing: Boolean(ln.match(/<\/.+>/)),
|
||||
opening: Boolean(ln.match(/<[^!?].*>/))
|
||||
};
|
||||
type = ((function() {
|
||||
var _results;
|
||||
_results = [];
|
||||
for (key in types) {
|
||||
value = types[key];
|
||||
if (value) {
|
||||
_results.push(key);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
})())[0];
|
||||
type = type === void 0 ? 'other' : type;
|
||||
fromTo = lastType + '->' + type;
|
||||
lastType = type;
|
||||
padding = '';
|
||||
indent += transitions[fromTo];
|
||||
padding = ((function() {
|
||||
var _j, _ref5, _results;
|
||||
_results = [];
|
||||
for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
|
||||
_results.push(' ');
|
||||
}
|
||||
return _results;
|
||||
})()).join('');
|
||||
if (fromTo === 'opening->closing') {
|
||||
return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
|
||||
} else {
|
||||
return formatted += padding + ln + '\n';
|
||||
}
|
||||
};
|
||||
for (_i = 0, _len = lines.length; _i < _len; _i++) {
|
||||
ln = lines[_i];
|
||||
_fn(ln);
|
||||
}
|
||||
return formatted;
|
||||
};
|
||||
|
||||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) {
|
||||
var _this = this;
|
||||
var errors = [];
|
||||
@@ -1403,6 +1497,9 @@ PasswordAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
|
||||
var e = (typeof window !== 'undefined' ? window : exports);
|
||||
|
||||
var sampleModels = {};
|
||||
|
||||
e.SampleModels = sampleModels;
|
||||
e.SwaggerHttp = SwaggerHttp;
|
||||
e.SwaggerRequest = SwaggerRequest;
|
||||
e.authorizations = new SwaggerAuthorizations();
|
||||
@@ -1415,3 +1512,4 @@ e.SwaggerModel = SwaggerModel;
|
||||
e.SwaggerModelProperty = SwaggerModelProperty;
|
||||
e.SwaggerResource = SwaggerResource;
|
||||
e.SwaggerApi = SwaggerApi;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.14",
|
||||
"version": "2.0.15",
|
||||
"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.26",
|
||||
"swagger-client": "2.0.29",
|
||||
"handlebars": "~1.0.10",
|
||||
"less": "~1.4.2"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user