Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
264ba2910d | ||
|
|
7b3b7066eb | ||
|
|
7a91117b6f | ||
|
|
9b0aa32941 | ||
|
|
b1964254c5 | ||
|
|
3a7b66d345 | ||
|
|
5da60bfa62 | ||
|
|
f8991bc7f5 | ||
|
|
ec81d25cb0 | ||
|
|
2b08c0e209 | ||
|
|
ee199633f6 | ||
|
|
4ea20859c7 | ||
|
|
0a52e344e7 | ||
|
|
e04b756521 | ||
|
|
28c7597138 |
@@ -62,6 +62,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
|
||||
* *sorter* apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
|
||||
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||
* *highlightSizeThreshold* any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses
|
||||
* All other parameters are explained in greater detail below
|
||||
|
||||
|
||||
|
||||
Vendored
+8
-5
@@ -743,17 +743,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
|
||||
outline: 2px solid black;
|
||||
outline-color: #cc0000;
|
||||
|
||||
Vendored
+5
-5
@@ -74,13 +74,13 @@ function handleLogin() {
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var redirectUrl = host.protocol + '//' + host.host + "/o2c.html";
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
|
||||
var url = null;
|
||||
|
||||
var p = window.swaggerUi.api.authSchemes;
|
||||
for (var key in p) {
|
||||
if (p.hasOwnProperty(key)) {
|
||||
var o = p[key].grantTypes;
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
var o = authSchemes[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
|
||||
Vendored
+140
-92
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.34
|
||||
// version 2.0.39
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -15,6 +15,16 @@ log = function(){
|
||||
}
|
||||
};
|
||||
|
||||
// if you want to apply conditional formatting of parameter values
|
||||
parameterMacro = function(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// if you want to apply conditional formatting of model property values
|
||||
modelPropertyMacro = function(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function(obj, start) {
|
||||
for (var i = (start || 0), j = this.length; i < j; i++) {
|
||||
@@ -45,42 +55,42 @@ if (!('map' in Array.prototype)) {
|
||||
}
|
||||
|
||||
Object.keys = Object.keys || (function () {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
var SwaggerApi = function(url, options) {
|
||||
this.isBuilt = false;
|
||||
this.url = null;
|
||||
this.debug = false;
|
||||
this.basePath = null;
|
||||
@@ -88,6 +98,7 @@ var SwaggerApi = function(url, options) {
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
this.modelsArray = [];
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -109,11 +120,15 @@ var SwaggerApi = function(url, options) {
|
||||
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
if (options.success != null)
|
||||
if (options.success != null) {
|
||||
this.build();
|
||||
this.isBuilt = true;
|
||||
}
|
||||
}
|
||||
|
||||
SwaggerApi.prototype.build = function() {
|
||||
if(this.isBuilt)
|
||||
return this;
|
||||
var _this = this;
|
||||
this.progress('fetching resource list: ' + this.url);
|
||||
var obj = {
|
||||
@@ -121,7 +136,7 @@ SwaggerApi.prototype.build = function() {
|
||||
url: this.url,
|
||||
method: "get",
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
error: function(response) {
|
||||
@@ -158,6 +173,7 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.consumes = response.consumes;
|
||||
this.produces = response.produces;
|
||||
this.authSchemes = response.authorizations;
|
||||
if (response.info != null) {
|
||||
@@ -175,13 +191,13 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
if (response.basePath)
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
else if (this.url.indexOf('?') > 0)
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
else
|
||||
this.basePath = this.url;
|
||||
}
|
||||
|
||||
if (isApi) {
|
||||
var newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
@@ -276,7 +292,6 @@ SwaggerApi.prototype.fail = function(message) {
|
||||
|
||||
SwaggerApi.prototype.setConsolidatedModels = function() {
|
||||
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
|
||||
this.modelsArray = [];
|
||||
this.models = {};
|
||||
_ref = this.apis;
|
||||
for (resource_name in _ref) {
|
||||
@@ -321,8 +336,8 @@ var SwaggerResource = function(resourceObj, api) {
|
||||
var _this = this;
|
||||
this.api = api;
|
||||
this.api = this.api;
|
||||
produces = [];
|
||||
consumes = [];
|
||||
consumes = (this.consumes | []);
|
||||
produces = (this.produces | []);
|
||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||
this.description = resourceObj.description;
|
||||
|
||||
@@ -353,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
|
||||
method: "get",
|
||||
useJQuery: this.useJQuery,
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
response: function(resp) {
|
||||
@@ -593,6 +608,7 @@ var SwaggerModelProperty = function(name, obj) {
|
||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||
this.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
this.defaultValue = modelPropertyMacro(obj.defaultValue);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
@@ -638,7 +654,9 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||
|
||||
SwaggerModelProperty.prototype.toSampleValue = function(value) {
|
||||
var result;
|
||||
if (value === "integer") {
|
||||
if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
|
||||
result = this.defaultValue;
|
||||
} else if (value === "integer") {
|
||||
result = 0;
|
||||
} else if (value === "boolean") {
|
||||
result = false;
|
||||
@@ -768,6 +786,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
|
||||
}
|
||||
}
|
||||
}
|
||||
param.defaultValue = parameterMacro(param.defaultValue);
|
||||
}
|
||||
this.resource[this.nickname] = function(args, callback, error) {
|
||||
return _this["do"](args, callback, error);
|
||||
@@ -1104,27 +1123,47 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
var body = params.body;
|
||||
|
||||
// encode the body for form submits
|
||||
if (headers["Accept"] && headers["Accept"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
if (headers["Content-Type"]) {
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
values[param.name] = param;
|
||||
var i;
|
||||
var operationParams = this.operation.parameters;
|
||||
for(i = 0; i < operationParams.length; i++) {
|
||||
var param = operationParams[i];
|
||||
if(param.paramType === "form")
|
||||
values[param.name] = param;
|
||||
}
|
||||
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
|
||||
// encode the body for form submits
|
||||
var data = "";
|
||||
var boundary = "----SwaggerFormBoundary" + Date.now();
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined') {
|
||||
data += '--' + boundary + '\n';
|
||||
data += 'Content-Disposition: form-data; name="' + key + '"';
|
||||
data += '\n\n';
|
||||
data += value + "\n";
|
||||
}
|
||||
}
|
||||
data += "--" + boundary + "--\n";
|
||||
headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
|
||||
body = data;
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
|
||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||
@@ -1171,7 +1210,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// default type
|
||||
var accepts = "application/json";
|
||||
var contentType = null;
|
||||
var consumes = "application/json";
|
||||
|
||||
var allDefinedParams = this.operation.parameters;
|
||||
var definedFormParams = [];
|
||||
@@ -1198,25 +1237,25 @@ SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// if there's a body, need to set the accepts header via requestContentType
|
||||
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
|
||||
if (this.opts.requestContentType)
|
||||
accepts = this.opts.requestContentType;
|
||||
consumes = this.opts.requestContentType;
|
||||
} else {
|
||||
// if any form params, content type must be set
|
||||
if(definedFormParams.length > 0) {
|
||||
if(definedFileParams.length > 0)
|
||||
accepts = "multipart/form-data";
|
||||
consumes = "multipart/form-data";
|
||||
else
|
||||
accepts = "application/x-www-form-urlencoded";
|
||||
consumes = "application/x-www-form-urlencoded";
|
||||
}
|
||||
else if (this.type == "DELETE")
|
||||
else if (this.type === "DELETE")
|
||||
body = "{}";
|
||||
else if (this.type != "DELETE")
|
||||
accepts = null;
|
||||
}
|
||||
|
||||
if (contentType && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(contentType) === -1) {
|
||||
log("server doesn't consume " + contentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||
contentType = this.operation.consumes[0];
|
||||
if (consumes && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(consumes) === -1) {
|
||||
log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
|
||||
consumes = this.operation.consumes[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1231,33 +1270,11 @@ SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
accepts = this.operation.produces[0];
|
||||
}
|
||||
}
|
||||
if (contentType && contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
values[param.name] = param;
|
||||
}
|
||||
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
if ((contentType && body !== "") || (contentType === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = contentType;
|
||||
if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = consumes;
|
||||
if (accepts)
|
||||
headers["Accept"] = accepts;
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
@@ -1463,11 +1480,36 @@ ShredHttpClient.prototype.execute = function(obj) {
|
||||
return out;
|
||||
};
|
||||
|
||||
// Transform an error into a usable response-like object
|
||||
var transformError = function(error) {
|
||||
var out = {
|
||||
// Default to a status of 0 - The client will treat this as a generic permissions sort of error
|
||||
status: 0,
|
||||
data: error.message || error
|
||||
};
|
||||
|
||||
if(error.code) {
|
||||
out.obj = error;
|
||||
|
||||
if(error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED' ) {
|
||||
// We can tell the client that this should be treated as a missing resource and not as a permissions thing
|
||||
out.status = 404;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
res = {
|
||||
error: function(response) {
|
||||
if (obj)
|
||||
return cb.error(transform(response));
|
||||
},
|
||||
// Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
|
||||
request_error: function(err) {
|
||||
if(obj)
|
||||
return cb.error(transformError(err));
|
||||
},
|
||||
redirect: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
@@ -1535,10 +1577,11 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
|
||||
/**
|
||||
* ApiKeyAuthorization allows a query param or header to be injected
|
||||
*/
|
||||
var ApiKeyAuthorization = function(name, value, type) {
|
||||
var ApiKeyAuthorization = function(name, value, type, delimiter) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.delimiter = delimiter;
|
||||
};
|
||||
|
||||
ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
@@ -1549,7 +1592,12 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
obj.url = obj.url + "?" + this.name + "=" + this.value;
|
||||
return true;
|
||||
} else if (this.type === "header") {
|
||||
obj.headers[this.name] = this.value;
|
||||
if(typeof obj.headers[this.name] !== 'undefined') {
|
||||
if(typeof this.delimiter !== 'undefined')
|
||||
obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
|
||||
}
|
||||
else
|
||||
obj.headers[this.name] = this.value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Vendored
+32
-14
@@ -1,5 +1,5 @@
|
||||
// swagger-ui.js
|
||||
// version 2.0.19
|
||||
// version 2.0.23
|
||||
$(function() {
|
||||
|
||||
// Helper function for vertically aligning DOM elements
|
||||
@@ -396,7 +396,7 @@ function program18(depth0,data) {
|
||||
function program20(depth0,data) {
|
||||
|
||||
|
||||
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";
|
||||
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n ";
|
||||
}
|
||||
|
||||
buffer += "\n <ul class='operations' >\n <li class='";
|
||||
@@ -1081,11 +1081,11 @@ function program1(depth0,data) {
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "' onclick=\"Docs.toggleEndpointListForResource('";
|
||||
+ "' class=\"toggleEndpointList\" data-id=\"";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "');\">";
|
||||
+ "\">";
|
||||
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -1106,19 +1106,19 @@ function program1(depth0,data) {
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'\n onclick=\"Docs.toggleEndpointListForResource('";
|
||||
+ "' class=\"toggleEndpointList\" data-id=\"";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "');\">Show/Hide</a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.collapseOperationsForResource('";
|
||||
+ "\">Show/Hide</a>\n </li>\n <li>\n <a href='#' class=\"collapseResource\" data-id=\"";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'); return false;\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' onclick=\"Docs.expandOperationsForResource('";
|
||||
+ "\">\n List Operations\n </a>\n </li>\n <li>\n <a href='#' class=\"expandResource\" data-id=";
|
||||
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
+ "'); return false;\">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
|
||||
+ ">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
|
||||
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
|
||||
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
|
||||
buffer += escapeExpression(stack1)
|
||||
@@ -1495,7 +1495,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
model: resource,
|
||||
tagName: 'li',
|
||||
id: 'resource_' + resource.id,
|
||||
className: 'resource'
|
||||
className: 'resource',
|
||||
swaggerOptions: this.options.swaggerOptions
|
||||
});
|
||||
return $('#resources').append(resourceView.render().el);
|
||||
};
|
||||
@@ -1536,6 +1537,9 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
operation.parentId = this.model.id;
|
||||
this.addOperation(operation);
|
||||
}
|
||||
$('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
|
||||
$('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
|
||||
$('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResoruce'));
|
||||
return this;
|
||||
};
|
||||
|
||||
@@ -1545,12 +1549,18 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
operationView = new OperationView({
|
||||
model: operation,
|
||||
tagName: 'li',
|
||||
className: 'endpoint'
|
||||
className: 'endpoint',
|
||||
swaggerOptions: this.options.swaggerOptions
|
||||
});
|
||||
$('.endpoints', $(this.el)).append(operationView.render().el);
|
||||
return this.number++;
|
||||
};
|
||||
|
||||
ResourceView.prototype.callDocs = function(fnName, e) {
|
||||
e.preventDefault();
|
||||
return Docs[fnName](e.currentTarget.getAttribute('data-id'));
|
||||
};
|
||||
|
||||
return ResourceView;
|
||||
|
||||
})(Backbone.View);
|
||||
@@ -1808,7 +1818,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
}
|
||||
}
|
||||
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></pre>");
|
||||
$(".request_url pre", $(this.el)).text(this.invocationUrl);
|
||||
obj = {
|
||||
type: this.model.method,
|
||||
url: this.invocationUrl,
|
||||
@@ -1975,7 +1986,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
};
|
||||
|
||||
OperationView.prototype.showStatus = function(response) {
|
||||
var code, content, contentType, headers, pre, response_body, url;
|
||||
var code, content, contentType, headers, opts, pre, response_body, response_body_el, url;
|
||||
if (response.content === void 0) {
|
||||
content = response.data;
|
||||
url = response.url;
|
||||
@@ -2004,14 +2015,21 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
|
||||
pre = $('<pre class="json" />').append(code);
|
||||
}
|
||||
response_body = pre;
|
||||
$(".request_url", $(this.el)).html("<pre>" + url + "</pre>");
|
||||
$(".request_url", $(this.el)).html("<pre></pre>");
|
||||
$(".request_url pre", $(this.el)).text(url);
|
||||
$(".response_code", $(this.el)).html("<pre>" + response.status + "</pre>");
|
||||
$(".response_body", $(this.el)).html(response_body);
|
||||
$(".response_headers", $(this.el)).html("<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>");
|
||||
$(".response", $(this.el)).slideDown();
|
||||
$(".response_hider", $(this.el)).show();
|
||||
$(".response_throbber", $(this.el)).hide();
|
||||
return hljs.highlightBlock($('.response_body', $(this.el))[0]);
|
||||
response_body_el = $('.response_body', $(this.el))[0];
|
||||
opts = this.options.swaggerOptions;
|
||||
if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) {
|
||||
return response_body_el;
|
||||
} else {
|
||||
return hljs.highlightBlock(response_body_el);
|
||||
}
|
||||
};
|
||||
|
||||
OperationView.prototype.toggleOperationContent = function() {
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -74,13 +74,13 @@ function handleLogin() {
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var host = window.location;
|
||||
var redirectUrl = host.protocol + '//' + host.host + "/o2c.html";
|
||||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
|
||||
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
|
||||
var url = null;
|
||||
|
||||
var p = window.swaggerUi.api.authSchemes;
|
||||
for (var key in p) {
|
||||
if (p.hasOwnProperty(key)) {
|
||||
var o = p[key].grantTypes;
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
var o = authSchemes[key].grantTypes;
|
||||
for(var t in o) {
|
||||
if(o.hasOwnProperty(t) && t === 'implicit') {
|
||||
var dets = o[t];
|
||||
|
||||
+140
-92
@@ -1,5 +1,5 @@
|
||||
// swagger.js
|
||||
// version 2.0.34
|
||||
// version 2.0.39
|
||||
|
||||
var __bind = function(fn, me){
|
||||
return function(){
|
||||
@@ -15,6 +15,16 @@ log = function(){
|
||||
}
|
||||
};
|
||||
|
||||
// if you want to apply conditional formatting of parameter values
|
||||
parameterMacro = function(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
// if you want to apply conditional formatting of model property values
|
||||
modelPropertyMacro = function(value) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!Array.prototype.indexOf) {
|
||||
Array.prototype.indexOf = function(obj, start) {
|
||||
for (var i = (start || 0), j = this.length; i < j; i++) {
|
||||
@@ -45,42 +55,42 @@ if (!('map' in Array.prototype)) {
|
||||
}
|
||||
|
||||
Object.keys = Object.keys || (function () {
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
var hasOwnProperty = Object.prototype.hasOwnProperty,
|
||||
hasDontEnumBug = !{toString:null}.propertyIsEnumerable("toString"),
|
||||
DontEnums = [
|
||||
'toString',
|
||||
'toLocaleString',
|
||||
'valueOf',
|
||||
'hasOwnProperty',
|
||||
'isPrototypeOf',
|
||||
'propertyIsEnumerable',
|
||||
'constructor'
|
||||
],
|
||||
DontEnumsLength = DontEnums.length;
|
||||
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
return function (o) {
|
||||
if (typeof o != "object" && typeof o != "function" || o === null)
|
||||
throw new TypeError("Object.keys called on a non-object");
|
||||
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
var result = [];
|
||||
for (var name in o) {
|
||||
if (hasOwnProperty.call(o, name))
|
||||
result.push(name);
|
||||
}
|
||||
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
if (hasDontEnumBug) {
|
||||
for (var i = 0; i < DontEnumsLength; i++) {
|
||||
if (hasOwnProperty.call(o, DontEnums[i]))
|
||||
result.push(DontEnums[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
return result;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
var SwaggerApi = function(url, options) {
|
||||
this.isBuilt = false;
|
||||
this.url = null;
|
||||
this.debug = false;
|
||||
this.basePath = null;
|
||||
@@ -88,6 +98,7 @@ var SwaggerApi = function(url, options) {
|
||||
this.authorizationScheme = null;
|
||||
this.info = null;
|
||||
this.useJQuery = false;
|
||||
this.modelsArray = [];
|
||||
|
||||
options = (options||{});
|
||||
if (url)
|
||||
@@ -109,11 +120,15 @@ var SwaggerApi = function(url, options) {
|
||||
|
||||
this.failure = options.failure != null ? options.failure : function() {};
|
||||
this.progress = options.progress != null ? options.progress : function() {};
|
||||
if (options.success != null)
|
||||
if (options.success != null) {
|
||||
this.build();
|
||||
this.isBuilt = true;
|
||||
}
|
||||
}
|
||||
|
||||
SwaggerApi.prototype.build = function() {
|
||||
if(this.isBuilt)
|
||||
return this;
|
||||
var _this = this;
|
||||
this.progress('fetching resource list: ' + this.url);
|
||||
var obj = {
|
||||
@@ -121,7 +136,7 @@ SwaggerApi.prototype.build = function() {
|
||||
url: this.url,
|
||||
method: "get",
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
error: function(response) {
|
||||
@@ -158,6 +173,7 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
}
|
||||
this.apis = {};
|
||||
this.apisArray = [];
|
||||
this.consumes = response.consumes;
|
||||
this.produces = response.produces;
|
||||
this.authSchemes = response.authorizations;
|
||||
if (response.info != null) {
|
||||
@@ -175,13 +191,13 @@ SwaggerApi.prototype.buildFromSpec = function(response) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (response.basePath) {
|
||||
if (response.basePath)
|
||||
this.basePath = response.basePath;
|
||||
} else if (this.url.indexOf('?') > 0) {
|
||||
else if (this.url.indexOf('?') > 0)
|
||||
this.basePath = this.url.substring(0, this.url.lastIndexOf('?'));
|
||||
} else {
|
||||
else
|
||||
this.basePath = this.url;
|
||||
}
|
||||
|
||||
if (isApi) {
|
||||
var newName = response.resourcePath.replace(/\//g, '');
|
||||
this.resourcePath = response.resourcePath;
|
||||
@@ -276,7 +292,6 @@ SwaggerApi.prototype.fail = function(message) {
|
||||
|
||||
SwaggerApi.prototype.setConsolidatedModels = function() {
|
||||
var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results;
|
||||
this.modelsArray = [];
|
||||
this.models = {};
|
||||
_ref = this.apis;
|
||||
for (resource_name in _ref) {
|
||||
@@ -321,8 +336,8 @@ var SwaggerResource = function(resourceObj, api) {
|
||||
var _this = this;
|
||||
this.api = api;
|
||||
this.api = this.api;
|
||||
produces = [];
|
||||
consumes = [];
|
||||
consumes = (this.consumes | []);
|
||||
produces = (this.produces | []);
|
||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||
this.description = resourceObj.description;
|
||||
|
||||
@@ -353,7 +368,7 @@ var SwaggerResource = function(resourceObj, api) {
|
||||
method: "get",
|
||||
useJQuery: this.useJQuery,
|
||||
headers: {
|
||||
accept: "application/json"
|
||||
accept: "application/json,application/json;charset=\"utf-8\",*/*"
|
||||
},
|
||||
on: {
|
||||
response: function(resp) {
|
||||
@@ -593,6 +608,7 @@ var SwaggerModelProperty = function(name, obj) {
|
||||
this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set');
|
||||
this.descr = obj.description;
|
||||
this.required = obj.required;
|
||||
this.defaultValue = modelPropertyMacro(obj.defaultValue);
|
||||
if (obj.items != null) {
|
||||
if (obj.items.type != null) {
|
||||
this.refDataType = obj.items.type;
|
||||
@@ -638,7 +654,9 @@ SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) {
|
||||
|
||||
SwaggerModelProperty.prototype.toSampleValue = function(value) {
|
||||
var result;
|
||||
if (value === "integer") {
|
||||
if ((typeof this.defaultValue !== 'undefined') && this.defaultValue !== null) {
|
||||
result = this.defaultValue;
|
||||
} else if (value === "integer") {
|
||||
result = 0;
|
||||
} else if (value === "boolean") {
|
||||
result = false;
|
||||
@@ -768,6 +786,7 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not
|
||||
}
|
||||
}
|
||||
}
|
||||
param.defaultValue = parameterMacro(param.defaultValue);
|
||||
}
|
||||
this.resource[this.nickname] = function(args, callback, error) {
|
||||
return _this["do"](args, callback, error);
|
||||
@@ -1104,27 +1123,47 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
var body = params.body;
|
||||
|
||||
// encode the body for form submits
|
||||
if (headers["Accept"] && headers["Accept"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
if (headers["Content-Type"]) {
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
values[param.name] = param;
|
||||
var i;
|
||||
var operationParams = this.operation.parameters;
|
||||
for(i = 0; i < operationParams.length; i++) {
|
||||
var param = operationParams[i];
|
||||
if(param.paramType === "form")
|
||||
values[param.name] = param;
|
||||
}
|
||||
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) {
|
||||
// encode the body for form submits
|
||||
var data = "";
|
||||
var boundary = "----SwaggerFormBoundary" + Date.now();
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined') {
|
||||
data += '--' + boundary + '\n';
|
||||
data += 'Content-Disposition: form-data; name="' + key + '"';
|
||||
data += '\n\n';
|
||||
data += value + "\n";
|
||||
}
|
||||
}
|
||||
data += "--" + boundary + "--\n";
|
||||
headers["Content-Type"] = "multipart/form-data; boundary=" + boundary;
|
||||
body = data;
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
|
||||
if (!((this.headers != null) && (this.headers.mock != null))) {
|
||||
@@ -1171,7 +1210,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal
|
||||
SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// default type
|
||||
var accepts = "application/json";
|
||||
var contentType = null;
|
||||
var consumes = "application/json";
|
||||
|
||||
var allDefinedParams = this.operation.parameters;
|
||||
var definedFormParams = [];
|
||||
@@ -1198,25 +1237,25 @@ SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
// if there's a body, need to set the accepts header via requestContentType
|
||||
if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) {
|
||||
if (this.opts.requestContentType)
|
||||
accepts = this.opts.requestContentType;
|
||||
consumes = this.opts.requestContentType;
|
||||
} else {
|
||||
// if any form params, content type must be set
|
||||
if(definedFormParams.length > 0) {
|
||||
if(definedFileParams.length > 0)
|
||||
accepts = "multipart/form-data";
|
||||
consumes = "multipart/form-data";
|
||||
else
|
||||
accepts = "application/x-www-form-urlencoded";
|
||||
consumes = "application/x-www-form-urlencoded";
|
||||
}
|
||||
else if (this.type == "DELETE")
|
||||
else if (this.type === "DELETE")
|
||||
body = "{}";
|
||||
else if (this.type != "DELETE")
|
||||
accepts = null;
|
||||
}
|
||||
|
||||
if (contentType && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(contentType) === -1) {
|
||||
log("server doesn't consume " + contentType + ", try " + JSON.stringify(this.operation.consumes));
|
||||
contentType = this.operation.consumes[0];
|
||||
if (consumes && this.operation.consumes) {
|
||||
if (this.operation.consumes.indexOf(consumes) === -1) {
|
||||
log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes));
|
||||
consumes = this.operation.consumes[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1231,33 +1270,11 @@ SwaggerRequest.prototype.setHeaders = function(params, operation) {
|
||||
accepts = this.operation.produces[0];
|
||||
}
|
||||
}
|
||||
if (contentType && contentType.indexOf("application/x-www-form-urlencoded") === 0) {
|
||||
var fields = {};
|
||||
var possibleParams = {};
|
||||
var values = {};
|
||||
var key;
|
||||
for(key in formParams){
|
||||
var param = formParams[key];
|
||||
values[param.name] = param;
|
||||
}
|
||||
|
||||
var encoded = "";
|
||||
var key;
|
||||
for(key in values) {
|
||||
value = this.params[key];
|
||||
if(typeof value !== 'undefined'){
|
||||
if(encoded !== "")
|
||||
encoded += "&";
|
||||
encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value);
|
||||
}
|
||||
}
|
||||
body = encoded;
|
||||
}
|
||||
if ((contentType && body !== "") || (contentType === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = contentType;
|
||||
if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded"))
|
||||
headers["Content-Type"] = consumes;
|
||||
if (accepts)
|
||||
headers["Accept"] = accepts;
|
||||
|
||||
return headers;
|
||||
}
|
||||
|
||||
@@ -1463,11 +1480,36 @@ ShredHttpClient.prototype.execute = function(obj) {
|
||||
return out;
|
||||
};
|
||||
|
||||
// Transform an error into a usable response-like object
|
||||
var transformError = function(error) {
|
||||
var out = {
|
||||
// Default to a status of 0 - The client will treat this as a generic permissions sort of error
|
||||
status: 0,
|
||||
data: error.message || error
|
||||
};
|
||||
|
||||
if(error.code) {
|
||||
out.obj = error;
|
||||
|
||||
if(error.code === 'ENOTFOUND' || error.code === 'ECONNREFUSED' ) {
|
||||
// We can tell the client that this should be treated as a missing resource and not as a permissions thing
|
||||
out.status = 404;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
};
|
||||
|
||||
res = {
|
||||
error: function(response) {
|
||||
if (obj)
|
||||
return cb.error(transform(response));
|
||||
},
|
||||
// Catch the Shred error raised when the request errors as it is made (i.e. No Response is coming)
|
||||
request_error: function(err) {
|
||||
if(obj)
|
||||
return cb.error(transformError(err));
|
||||
},
|
||||
redirect: function(response) {
|
||||
if (obj)
|
||||
return cb.redirect(transform(response));
|
||||
@@ -1535,10 +1577,11 @@ SwaggerAuthorizations.prototype.apply = function(obj, authorizations) {
|
||||
/**
|
||||
* ApiKeyAuthorization allows a query param or header to be injected
|
||||
*/
|
||||
var ApiKeyAuthorization = function(name, value, type) {
|
||||
var ApiKeyAuthorization = function(name, value, type, delimiter) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.delimiter = delimiter;
|
||||
};
|
||||
|
||||
ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
@@ -1549,7 +1592,12 @@ ApiKeyAuthorization.prototype.apply = function(obj, authorizations) {
|
||||
obj.url = obj.url + "?" + this.name + "=" + this.value;
|
||||
return true;
|
||||
} else if (this.type === "header") {
|
||||
obj.headers[this.name] = this.value;
|
||||
if(typeof obj.headers[this.name] !== 'undefined') {
|
||||
if(typeof this.delimiter !== 'undefined')
|
||||
obj.headers[this.name] = obj.headers[this.name] + this.delimiter + this.value;
|
||||
}
|
||||
else
|
||||
obj.headers[this.name] = this.value;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.19",
|
||||
"version": "2.0.24",
|
||||
"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.6.3",
|
||||
"swagger-client": "2.0.34",
|
||||
"swagger-client": "2.0.36",
|
||||
"handlebars": "~1.0.10",
|
||||
"less": "~1.4.2"
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class MainView extends Backbone.View
|
||||
|
||||
addResource: (resource) ->
|
||||
# Render a resource and add it to resources li
|
||||
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource'})
|
||||
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource', swaggerOptions: @options.swaggerOptions})
|
||||
$('#resources').append resourceView.render().el
|
||||
|
||||
clear: ->
|
||||
|
||||
@@ -186,8 +186,9 @@ class OperationView extends Backbone.View
|
||||
else
|
||||
@model.urlify(map, true)
|
||||
|
||||
$(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
|
||||
|
||||
$(".request_url", $(@el)).html("<pre></pre>")
|
||||
$(".request_url pre", $(@el)).text(@invocationUrl);
|
||||
|
||||
obj =
|
||||
type: @model.method
|
||||
url: @invocationUrl
|
||||
@@ -356,14 +357,18 @@ class OperationView extends Backbone.View
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
|
||||
response_body = pre
|
||||
$(".request_url", $(@el)).html "<pre>" + url + "</pre>"
|
||||
$(".request_url", $(@el)).html("<pre></pre>")
|
||||
$(".request_url pre", $(@el)).text(url);
|
||||
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
|
||||
$(".response_body", $(@el)).html response_body
|
||||
$(".response_headers", $(@el)).html "<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response", $(@el)).slideDown()
|
||||
$(".response_hider", $(@el)).show()
|
||||
$(".response_throbber", $(@el)).hide()
|
||||
hljs.highlightBlock($('.response_body', $(@el))[0])
|
||||
response_body_el = $('.response_body', $(@el))[0]
|
||||
# only highlight the response if response is less than threshold, default state is highlight response
|
||||
opts = @options.swaggerOptions
|
||||
if opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold then response_body_el else hljs.highlightBlock(response_body_el)
|
||||
|
||||
toggleOperationContent: ->
|
||||
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_content")
|
||||
|
||||
@@ -20,14 +20,27 @@ class ResourceView extends Backbone.View
|
||||
operation.nickname = id
|
||||
operation.parentId = @model.id
|
||||
@addOperation operation
|
||||
@
|
||||
|
||||
$('.toggleEndpointList', @el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'))
|
||||
$('.collapseResource', @el).click(this.callDocs.bind(this, 'collapseOperationsForResource'))
|
||||
$('.expandResource', @el).click(this.callDocs.bind(this, 'expandOperationsForResoruce'))
|
||||
|
||||
return @
|
||||
|
||||
addOperation: (operation) ->
|
||||
|
||||
operation.number = @number
|
||||
|
||||
# Render an operation and add it to operations li
|
||||
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
|
||||
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint', swaggerOptions: @options.swaggerOptions})
|
||||
$('.endpoints', $(@el)).append operationView.render().el
|
||||
|
||||
@number++
|
||||
@number++
|
||||
|
||||
#
|
||||
# Generic Event handler (`Docs` is global)
|
||||
#
|
||||
|
||||
callDocs: (fnName, e) ->
|
||||
e.preventDefault()
|
||||
Docs[fnName](e.currentTarget.getAttribute('data-id'))
|
||||
|
||||
@@ -743,17 +743,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
|
||||
outline: 2px solid black;
|
||||
outline-color: #cc0000;
|
||||
|
||||
@@ -671,17 +671,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
form {
|
||||
input[type='text'].error {
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class='sandbox_header'>
|
||||
<input class='submit' name='commit' type='button' value='Try it out!' />
|
||||
<a href='#' class='response_hider' style='display:none'>Hide Response</a>
|
||||
<img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />
|
||||
<span class='response_throbber' style='display:none'></span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
<div class='heading'>
|
||||
<h2>
|
||||
<a href='#!/{{id}}' onclick="Docs.toggleEndpointListForResource('{{id}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
|
||||
<a href='#!/{{id}}' class="toggleEndpointList" data-id="{{id}}">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
|
||||
</h2>
|
||||
<ul class='options'>
|
||||
<li>
|
||||
<a href='#!/{{id}}' id='endpointListTogger_{{id}}'
|
||||
onclick="Docs.toggleEndpointListForResource('{{id}}');">Show/Hide</a>
|
||||
<a href='#!/{{id}}' id='endpointListTogger_{{id}}' class="toggleEndpointList" data-id="{{id}}">Show/Hide</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='#' onclick="Docs.collapseOperationsForResource('{{id}}'); return false;">
|
||||
<a href='#' class="collapseResource" data-id="{{id}}">
|
||||
List Operations
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='#' onclick="Docs.expandOperationsForResource('{{id}}'); return false;">
|
||||
<a href='#' class="expandResource" data-id={{id}}>
|
||||
Expand Operations
|
||||
</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user