aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js')
-rw-r--r--MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js55
1 files changed, 31 insertions, 24 deletions
diff --git a/MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js b/MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js
index b1f3abfff..c6f0cd379 100644
--- a/MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js
+++ b/MediaBrowser.Server.Implementations/swagger-ui/lib/swagger.js
@@ -324,7 +324,7 @@
return _results;
};
- SwaggerModel.prototype.getMockSignature = function(prefix, modelsToIgnore) {
+ SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) {
var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1;
propertiesStr = [];
_ref = this.properties;
@@ -332,15 +332,12 @@
prop = _ref[_i];
propertiesStr.push(prop.toString());
}
- strong = '<span style="font-weight: bold; color: #000; font-size: 1.0em">';
- stronger = '<span style="font-weight: bold; color: #000; font-size: 1.1em">';
+ strong = '<span class="strong">';
+ stronger = '<span class="stronger">';
strongClose = '</span>';
- classOpen = strong + 'class ' + this.name + '(' + strongClose;
- classClose = strong + ')' + strongClose;
- returnVal = classOpen + '<span>' + propertiesStr.join('</span>, <span>') + '</span>' + classClose;
- if (prefix != null) {
- returnVal = stronger + prefix + strongClose + '<br/>' + returnVal;
- }
+ classOpen = strong + this.name + ' {' + strongClose;
+ classClose = strong + '}' + strongClose;
+ returnVal = classOpen + '<div>' + propertiesStr.join(',</div><div>') + '</div>' + classClose;
if (!modelsToIgnore) {
modelsToIgnore = [];
}
@@ -349,19 +346,21 @@
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
prop = _ref1[_j];
if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) {
- returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(void 0, modelsToIgnore));
+ returnVal = returnVal + ('<br>' + prop.refModel.getMockSignature(modelsToIgnore));
}
}
return returnVal;
};
- SwaggerModel.prototype.createJSONSample = function(modelToIgnore) {
+ SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) {
var prop, result, _i, _len, _ref;
result = {};
+ modelsToIgnore = modelsToIgnore || [];
+ modelsToIgnore.push(this.name);
_ref = this.properties;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
prop = _ref[_i];
- result[prop.name] = prop.getSampleValue(modelToIgnore);
+ result[prop.name] = prop.getSampleValue(modelsToIgnore);
}
return result;
};
@@ -375,8 +374,9 @@
function SwaggerModelProperty(name, obj) {
this.name = name;
this.dataType = obj.type;
- this.isArray = this.dataType.toLowerCase() === 'array';
+ this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
this.descr = obj.description;
+ this.required = obj.required;
if (obj.items != null) {
if (obj.items.type != null) {
this.refDataType = obj.items.type;
@@ -395,18 +395,18 @@
}
}
- SwaggerModelProperty.prototype.getSampleValue = function(modelToIgnore) {
+ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
var result;
- if ((this.refModel != null) && (!(this.refModel === modelToIgnore))) {
- result = this.refModel.createJSONSample(this.refModel);
+ if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) {
+ result = this.refModel.createJSONSample(modelsToIgnore);
} else {
- if (this.isArray) {
+ if (this.isCollection) {
result = this.refDataType;
} else {
result = this.dataType;
}
}
- if (this.isArray) {
+ if (this.isCollection) {
return [result];
} else {
return result;
@@ -414,13 +414,18 @@
};
SwaggerModelProperty.prototype.toString = function() {
- var str;
- str = this.name + ': ' + this.dataTypeWithRef;
+ var req, str;
+ req = this.required ? 'propReq' : 'propOpt';
+ str = '<span class="propName ' + req + '">' + this.name + '</span> (<span class="propType">' + this.dataTypeWithRef + '</span>';
+ if (!this.required) {
+ str += ', <span class="propOptKey">optional</span>';
+ }
+ str += ')';
if (this.values != null) {
- str += " = ['" + this.values.join("' or '") + "']";
+ str += " = <span class='propVals'>['" + this.values.join("' or '") + "']</span>";
}
if (this.descr != null) {
- str += ' {' + this.descr + '}';
+ str += ': <span class="propDesc">' + this.descr + '</span>';
}
return str;
};
@@ -525,9 +530,9 @@
return dataType;
} else {
if (listType != null) {
- return models[listType].getMockSignature(dataType);
+ return models[listType].getMockSignature();
} else {
- return models[dataType].getMockSignature(dataType);
+ return models[dataType].getMockSignature();
}
}
};
@@ -762,4 +767,6 @@
window.SwaggerRequest = SwaggerRequest;
+ window.SwaggerModelProperty = SwaggerModelProperty;
+
}).call(this);