@@ -2,7 +2,7 @@ | |||
<html> | |||
<head> | |||
<title>Swagger UI</title> | |||
<link href='https://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/> | |||
<link href='//fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'/> | |||
<link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/> | |||
<link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/> | |||
<link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/> | |||
@@ -25,7 +25,7 @@ | |||
<script type="text/javascript"> | |||
$(function () { | |||
window.swaggerUi = new SwaggerUi({ | |||
url: "http://localhost:8002/api/api-docs", | |||
url: "http://petstore.swagger.wordnik.com/api/api-docs", | |||
dom_id: "swagger-ui-container", | |||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'], | |||
onComplete: function(swaggerApi, swaggerUi){ | |||
@@ -55,11 +55,9 @@ | |||
log("key: " + key); | |||
if(key && key.trim() != "") { | |||
log("added key " + key); | |||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "header")); | |||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query")); | |||
} | |||
}) | |||
window.authorizations.add("key1", new ApiKeyAuthorization("key1", "the_key_1", "header")); | |||
window.authorizations.add("key2", new ApiKeyAuthorization("key2", "the_key_2", "header")); | |||
window.swaggerUi.load(); | |||
}); | |||
</script> | |||
@@ -2131,12 +2131,10 @@ require.define("/shred/mixins/headers.js", function (require, module, exports, _ | |||
// to `Content-Type`. | |||
var corsetCase = function(string) { | |||
return string; | |||
/* return string.toLowerCase() | |||
return string.toLowerCase() | |||
//.replace("_","-") | |||
.replace(/(^|-)(\w)/g, | |||
function(s) { return s.toUpperCase(); }); | |||
*/ | |||
}; | |||
// We suspect that `initializeHeaders` was once more complicated ... | |||
@@ -48,65 +48,72 @@ function handleLogin() { | |||
str += '</label></li>'; | |||
popup.append(str); | |||
} | |||
} | |||
var $win = $(window), | |||
dw = $win.width(), | |||
dh = $win.height(), | |||
st = $win.scrollTop(), | |||
dlgWd = popupDialog.outerWidth(), | |||
dlgHt = popupDialog.outerHeight(), | |||
top = (dh -dlgHt)/2 + st, | |||
left = (dw - dlgWd)/2; | |||
popupDialog.css({ | |||
top: (top < 0? 0 : top) + 'px', | |||
left: (left < 0? 0 : left) + 'px' | |||
}); | |||
popupDialog.find('button.api-popup-cancel').click(function() { | |||
popupMask.hide(); | |||
popupDialog.hide(); | |||
}); | |||
popupDialog.find('button.api-popup-authbtn').click(function() { | |||
popupMask.hide(); | |||
popupDialog.hide(); | |||
var authSchemes = window.swaggerUi.api.authSchemes; | |||
var host = window.location; | |||
var redirectUrl = host.protocol + '//' + host.host + "/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 t in o) { | |||
if(o.hasOwnProperty(t) && t === 'implicit') { | |||
var dets = o[t]; | |||
url = dets.loginEndpoint.url + "?response_type=token"; | |||
window.swaggerUi.tokenName = dets.tokenName; | |||
var $win = $(window), | |||
dw = $win.width(), | |||
dh = $win.height(), | |||
st = $win.scrollTop(), | |||
dlgWd = popupDialog.outerWidth(), | |||
dlgHt = popupDialog.outerHeight(), | |||
top = (dh -dlgHt)/2 + st, | |||
left = (dw - dlgWd)/2; | |||
popupDialog.css({ | |||
top: (top < 0? 0 : top) + 'px', | |||
left: (left < 0? 0 : left) + 'px' | |||
}); | |||
popupDialog.find('button.api-popup-cancel').click(function() { | |||
popupMask.hide(); | |||
popupDialog.hide(); | |||
}); | |||
popupDialog.find('button.api-popup-authbtn').click(function() { | |||
popupMask.hide(); | |||
popupDialog.hide(); | |||
var authSchemes = window.swaggerUi.api.authSchemes; | |||
var location = window.location; | |||
var locationUrl = location.protocol + '//' + location.host + location.pathname; | |||
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/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 t in o) { | |||
if(o.hasOwnProperty(t) && t === 'implicit') { | |||
var dets = o[t]; | |||
url = dets.loginEndpoint.url + "?response_type=token"; | |||
window.swaggerUi.tokenName = dets.tokenName; | |||
} | |||
} | |||
} | |||
} | |||
} | |||
var scopes = [] | |||
var o = $('.api-popup-scopes').find('input:checked'); | |||
for(k =0; k < o.length; k++) { | |||
scopes.push($(o[k]).attr("scope")); | |||
} | |||
window.enabledScopes=scopes; | |||
var scopes = []; | |||
var scopeForUrl=''; | |||
var o = $('.api-popup-scopes').find('input:checked'); | |||
for(var k =0; k < o.length; k++) { | |||
scopes.push($(o[k]).attr("scope")); | |||
if(k > 0){ | |||
scopeForUrl+=' '; | |||
} | |||
scopeForUrl+=$(o[k]).attr("scope"); | |||
} | |||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl); | |||
url += '&realm=' + encodeURIComponent(realm); | |||
url += '&client_id=' + encodeURIComponent(clientId); | |||
url += '&scope=' + encodeURIComponent(scopes); | |||
window.enabledScopes=scopes; | |||
window.open(url); | |||
}); | |||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl); | |||
url += '&realm=' + encodeURIComponent(realm); | |||
url += '&client_id=' + encodeURIComponent(clientId); | |||
url += '&scope=' + encodeURIComponent(scopeForUrl); | |||
window.open(url); | |||
}); | |||
} | |||
popupMask.show(); | |||
popupDialog.show(); | |||
return; | |||
@@ -1,5 +1,5 @@ | |||
// swagger.js | |||
// version 2.0.30 | |||
// version 2.0.31 | |||
var __bind = function(fn, me){ | |||
return function(){ | |||
@@ -57,24 +57,24 @@ Object.keys = Object.keys || (function () { | |||
'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"); | |||
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]); | |||
} | |||
} | |||
} | |||
return result; | |||
}; | |||
})(); | |||
@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) { | |||
this.authorizations = null; | |||
this.authorizationScheme = null; | |||
this.info = null; | |||
this.useJQuery = false; | |||
options = (options||{}); | |||
if (url) | |||
@@ -103,6 +104,9 @@ var SwaggerApi = function(url, options) { | |||
if (options.success != null) | |||
this.success = options.success; | |||
if (typeof options.useJQuery === 'boolean') | |||
this.useJQuery = options.useJQuery; | |||
this.failure = options.failure != null ? options.failure : function() {}; | |||
this.progress = options.progress != null ? options.progress : function() {}; | |||
if (options.success != null) | |||
@@ -432,7 +436,6 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, | |||
output = []; | |||
for (var i = 0; i < ops.length; i++) { | |||
o = ops[i]; | |||
consumes = this.consumes; | |||
produces = this.produces; | |||
if (o.consumes != null) | |||
@@ -479,8 +482,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, | |||
SwaggerResource.prototype.sanitize = function(nickname) { | |||
var op; | |||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_'); | |||
//' | |||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_'); | |||
op = op.replace(/((_){2,})/g, '_'); | |||
op = op.replace(/^(_)*/g, ''); | |||
op = op.replace(/([_])*$/g, ''); | |||
@@ -675,7 +677,6 @@ var SwaggerOperation = function(nickname, path, method, parameters, summary, not | |||
this.resource = (resource||errors.push("Resource is required")); | |||
this.consumes = consumes; | |||
this.produces = produces; | |||
this.authorizations = authorizations; | |||
this["do"] = __bind(this["do"], this); | |||
@@ -814,7 +815,7 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) { | |||
else | |||
return JSON.stringify(val, null, 2); | |||
} | |||
else | |||
else | |||
return val; | |||
} | |||
}; | |||
@@ -1075,7 +1076,7 @@ SwaggerOperation.prototype.formatXml = function(xml) { | |||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) { | |||
var _this = this; | |||
var errors = []; | |||
this.useJQuery = (typeof operation.useJQuery !== 'undefined' ? operation.useJQuery : null); | |||
this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null); | |||
this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options).")); | |||
this.url = (url||errors.push("SwaggerRequest url is required.")); | |||
this.params = params; | |||
@@ -1123,6 +1124,8 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal | |||
else | |||
requestContentType = "application/x-www-form-urlencoded"; | |||
} | |||
else if (this.type == "DELETE") | |||
body = "{}"; | |||
else if (this.type != "DELETE") | |||
requestContentType = null; | |||
} | |||
@@ -1205,7 +1208,7 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal | |||
} else { | |||
e = exports; | |||
} | |||
status = e.authorizations.apply(obj, this.operation); | |||
status = e.authorizations.apply(obj, this.operation.authorizations); | |||
if (opts.mock == null) { | |||
if (status !== false) { | |||
new SwaggerHttp().execute(obj); | |||
@@ -1261,9 +1264,16 @@ SwaggerHttp.prototype.isIE8 = function() { | |||
}; | |||
/* | |||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic | |||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic. | |||
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space. | |||
* Since we are using closures here we need to alias it for internal use. | |||
*/ | |||
var JQueryHttpClient = function(options) {} | |||
var JQueryHttpClient = function(options) { | |||
"use strict"; | |||
if(!jQuery){ | |||
var jQuery = window.jQuery; | |||
} | |||
} | |||
JQueryHttpClient.prototype.execute = function(obj) { | |||
var cb = obj.on; | |||
@@ -1336,9 +1346,9 @@ JQueryHttpClient.prototype.execute = function(obj) { | |||
else | |||
return cb.response(out); | |||
}; | |||
$.support.cors = true; | |||
return $.ajax(obj); | |||
jQuery.support.cors = true; | |||
return jQuery.ajax(obj); | |||
} | |||
/* | |||
@@ -1453,33 +1463,32 @@ SwaggerAuthorizations.prototype.remove = function(name) { | |||
return delete this.authz[name]; | |||
}; | |||
SwaggerAuthorizations.prototype.apply = function(obj, operation) { | |||
status = null; | |||
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { | |||
var status = null; | |||
var key; | |||
for (key in this.authz) { | |||
var authorizations = (operation||{}).authorizations | |||
var applyAuth = false; | |||
if(operation) { | |||
if(!operation.authorizations) | |||
applyAuth = true; | |||
else if(typeof authorizations[key] !== 'undefined') | |||
applyAuth = true; | |||
} | |||
else { | |||
applyAuth = true; | |||
} | |||
value = this.authz[key]; | |||
if(applyAuth) { | |||
console.log('applying auth ' + key); | |||
if(typeof authorizations === 'undefined') { | |||
// apply all keys since no authorizations hash is defined | |||
for (key in this.authz) { | |||
value = this.authz[key]; | |||
result = value.apply(obj, authorizations); | |||
if (result === false) | |||
status = false; | |||
if (result === true) | |||
status = true; | |||
} | |||
else status = false; | |||
} | |||
else { | |||
for(name in authorizations) { | |||
for (key in this.authz) { | |||
if(key == name) { | |||
value = this.authz[key]; | |||
result = value.apply(obj, authorizations); | |||
if (result === true) | |||
status = true; | |||
} | |||
} | |||
} | |||
} | |||
return status; | |||
}; | |||
@@ -1492,7 +1501,7 @@ var ApiKeyAuthorization = function(name, value, type) { | |||
this.type = type; | |||
}; | |||
ApiKeyAuthorization.prototype.apply = function(obj, operation) { | |||
ApiKeyAuthorization.prototype.apply = function(obj, authorizations) { | |||
if (this.type === "query") { | |||
if (obj.url.indexOf('?') > 0) | |||
obj.url = obj.url + "&" + this.name + "=" + this.value; | |||
@@ -1509,7 +1518,7 @@ var CookieAuthorization = function(cookie) { | |||
this.cookie = cookie; | |||
} | |||
CookieAuthorization.prototype.apply = function(obj, operation) { | |||
CookieAuthorization.prototype.apply = function(obj, authorizations) { | |||
obj.cookieJar = obj.cookieJar || CookieJar(); | |||
obj.cookieJar.setCookie(this.cookie); | |||
return true; | |||
@@ -1529,7 +1538,7 @@ var PasswordAuthorization = function(name, username, password) { | |||
this._btoa = require("btoa"); | |||
}; | |||
PasswordAuthorization.prototype.apply = function(obj, operation) { | |||
PasswordAuthorization.prototype.apply = function(obj, authorizations) { | |||
var base64encoder = this._btoa; | |||
obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password); | |||
return true; | |||
@@ -1,5 +1,5 @@ | |||
// swagger.js | |||
// version 2.0.30 | |||
// version 2.0.31 | |||
var __bind = function(fn, me){ | |||
return function(){ | |||
@@ -57,24 +57,24 @@ Object.keys = Object.keys || (function () { | |||
'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"); | |||
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]); | |||
} | |||
} | |||
} | |||
return result; | |||
}; | |||
})(); | |||
@@ -87,6 +87,7 @@ var SwaggerApi = function(url, options) { | |||
this.authorizations = null; | |||
this.authorizationScheme = null; | |||
this.info = null; | |||
this.useJQuery = false; | |||
options = (options||{}); | |||
if (url) | |||
@@ -103,6 +104,9 @@ var SwaggerApi = function(url, options) { | |||
if (options.success != null) | |||
this.success = options.success; | |||
if (typeof options.useJQuery === 'boolean') | |||
this.useJQuery = options.useJQuery; | |||
this.failure = options.failure != null ? options.failure : function() {}; | |||
this.progress = options.progress != null ? options.progress : function() {}; | |||
if (options.success != null) | |||
@@ -478,8 +482,7 @@ SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, | |||
SwaggerResource.prototype.sanitize = function(nickname) { | |||
var op; | |||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_'); | |||
//' | |||
op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_'); | |||
op = op.replace(/((_){2,})/g, '_'); | |||
op = op.replace(/^(_)*/g, ''); | |||
op = op.replace(/([_])*$/g, ''); | |||
@@ -812,7 +815,7 @@ SwaggerOperation.prototype.getSampleJSON = function(type, models) { | |||
else | |||
return JSON.stringify(val, null, 2); | |||
} | |||
else | |||
else | |||
return val; | |||
} | |||
}; | |||
@@ -1073,7 +1076,7 @@ SwaggerOperation.prototype.formatXml = function(xml) { | |||
var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) { | |||
var _this = this; | |||
var errors = []; | |||
this.useJQuery = (typeof operation.useJQuery !== 'undefined' ? operation.useJQuery : null); | |||
this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null); | |||
this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options).")); | |||
this.url = (url||errors.push("SwaggerRequest url is required.")); | |||
this.params = params; | |||
@@ -1121,6 +1124,8 @@ var SwaggerRequest = function(type, url, params, opts, successCallback, errorCal | |||
else | |||
requestContentType = "application/x-www-form-urlencoded"; | |||
} | |||
else if (this.type == "DELETE") | |||
body = "{}"; | |||
else if (this.type != "DELETE") | |||
requestContentType = null; | |||
} | |||
@@ -1259,9 +1264,16 @@ SwaggerHttp.prototype.isIE8 = function() { | |||
}; | |||
/* | |||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic | |||
* JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic. | |||
* NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space. | |||
* Since we are using closures here we need to alias it for internal use. | |||
*/ | |||
var JQueryHttpClient = function(options) {} | |||
var JQueryHttpClient = function(options) { | |||
"use strict"; | |||
if(!jQuery){ | |||
var jQuery = window.jQuery; | |||
} | |||
} | |||
JQueryHttpClient.prototype.execute = function(obj) { | |||
var cb = obj.on; | |||
@@ -1334,9 +1346,9 @@ JQueryHttpClient.prototype.execute = function(obj) { | |||
else | |||
return cb.response(out); | |||
}; | |||
$.support.cors = true; | |||
return $.ajax(obj); | |||
jQuery.support.cors = true; | |||
return jQuery.ajax(obj); | |||
} | |||
/* | |||
@@ -1452,16 +1464,31 @@ SwaggerAuthorizations.prototype.remove = function(name) { | |||
}; | |||
SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { | |||
status = null; | |||
var status = null; | |||
var key; | |||
for (key in this.authz) { | |||
value = this.authz[key]; | |||
result = value.apply(obj, authorizations); | |||
if (result === false) | |||
status = false; | |||
if (result === true) | |||
status = true; | |||
if(typeof authorizations === 'undefined') { | |||
// apply all keys since no authorizations hash is defined | |||
for (key in this.authz) { | |||
value = this.authz[key]; | |||
result = value.apply(obj, authorizations); | |||
if (result === true) | |||
status = true; | |||
} | |||
} | |||
else { | |||
for(name in authorizations) { | |||
for (key in this.authz) { | |||
if(key == name) { | |||
value = this.authz[key]; | |||
result = value.apply(obj, authorizations); | |||
if (result === true) | |||
status = true; | |||
} | |||
} | |||
} | |||
} | |||
return status; | |||
}; | |||