assertThrow = function (passed, message) {
/*
* this function will throw the error <message> if <passed> is falsy
*/
var error;
if (passed) {
return;
}
error = (
// ternary-condition
(
message
&& typeof message.message === "string"
&& typeof message.stack === "string"
)
// if message is an error-object, then leave it as is
? message
: new Error(
typeof message === "string"
// if message is a string, then leave it as is
? message
// else JSON.stringify message
: JSON.stringify(message, null, 4)
)
);
throw error;
}
n/a
functionOrNop = function (fnc) {
/*
* this function will if <fnc> exists,
* them return <fnc>,
* else return <nop>
*/
return fnc || local.nop;
}
n/a
identity = function (value) {
/*
* this function will return <value>
*/
return value;
}
n/a
nop = function () {
/*
* this function will do nothing
*/
return;
}
n/a
function() { warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.'); SwaggerClient.ApiKeyAuthorization.apply(window, arguments); }
n/a
function() { warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.'); SwaggerClient.PasswordAuthorization.apply(window, arguments); }
n/a
SwaggerClient = function (url, options) { this.authorizations = null; this.authorizationScheme = null; this.basePath = null; this.debug = false; this.enableCookies = false; this.info = null; this.isBuilt = false; this.isValid = false; this.modelsArray = []; this.resourceCount = 0; this.url = null; this.useJQuery = false; this.jqueryAjaxCache = false; this.swaggerObject = {}; this.deferredClient = undefined; this.clientAuthorizations = new auth.SwaggerAuthorizations(); if (typeof url !== 'undefined') { return this.initialize(url, options); } else { return this; } }
n/a
function clientCredentialsFlow(scopes, tokenUrl, OAuthSchemeKey) { var params = { 'client_id': clientId, 'client_secret': clientSecret, 'scope': scopes.join(' '), 'grant_type': 'client_credentials' } $.ajax( { url : tokenUrl, type: "POST", data: params, success:function(data, textStatus, jqXHR) { onOAuthComplete(data,OAuthSchemeKey); }, error: function(jqXHR, textStatus, errorThrown) { onOAuthComplete(""); } }); }
n/a
function handleLogin() { var scopes = []; var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions; if(auths) { var key; var defs = auths; for(key in defs) { var auth = defs[key]; if(auth.type === 'oauth2' && auth.scopes) { var scope; if(Array.isArray(auth.scopes)) { // 1.2 support var i; for(i = 0; i < auth.scopes.length; i++) { scopes.push(auth.scopes[i]); } } else { // 2.0 support for(scope in auth.scopes) { scopes.push({scope: scope, description: auth.scopes[scope], OAuthSchemeKey: key}); } } } } } if(window.swaggerUi.api && window.swaggerUi.api.info) { appName = window.swaggerUi.api.info.title; } $('.api-popup-dialog').remove(); popupDialog = $( [ '<div class="api-popup-dialog">', '<div class="api-popup-title">Select OAuth2.0 Scopes</div>', '<div class="api-popup-content">', '<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.', '<a href="#">Learn how to use</a>', '</p>', '<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI .</p>', '<ul class="api-popup-scopes">', '</ul>', '<p class="error-msg"></p>', '<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>', '</div>', '</div>'].join('')); $(document.body).append(popupDialog); //TODO: only display applicable scopes (will need to pass them into handleLogin) popup = popupDialog.find('ul.api-popup-scopes').empty(); for (i = 0; i < scopes.length; i ++) { scope = scopes[i]; str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"' +'" oauthtype="' + scope.OAuthSchemeKey +'"/>' + '< label for="scope_' + i + '">' + scope.scope ; if (scope.description) { if ($.map(auths, function(n, i) { return i; }).length > 1) //if we have more than one scheme, display schemes str += '<br/><span class="api-scope-desc">' + scope.description + ' ('+ scope.OAuthSchemeKey+')' +'</span>'; else str += '<br/><span class="api-scope-desc">' + scope.description + '</span>'; } 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.empty(); popupDialog = []; }); $('button.api-popup-authbtn').unbind(); popupDialog.find('button.api-popup-authbtn').click(function() { popupMask.hide(); popupDialog.hide(); var authSchemes = window.swaggerUi.api.authSchem...
n/a
function handleLogout() { for(key in window.swaggerUi.api.clientAuthorizations.authz){ window.swaggerUi.api.clientAuthorizations.remove(key) } window.enabledScopes = null; $('.api-ic.ic-on').addClass('ic-off'); $('.api-ic.ic-on').removeClass('ic-on'); // set the info box $('.api-ic.ic-warning').addClass('ic-error'); $('.api-ic.ic-warning').removeClass('ic-warning'); }
n/a
function initOAuth(opts) { var o = (opts||{}); var errors = []; appName = (o.appName||errors.push('missing appName')); popupMask = (o.popupMask||$('#api-common-mask')); popupDialog = (o.popupDialog||$('.api-popup-dialog')); clientId = (o.clientId||errors.push('missing client id')); clientSecret = (o.clientSecret||null); realm = (o.realm||errors.push('missing realm')); scopeSeparator = (o.scopeSeparator||' '); additionalQueryStringParams = (o.additionalQueryStringParams||{}); if(errors.length > 0){ log('auth unable initialize oauth: ' + errors); return; } $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); $('.api-ic').unbind(); $('.api-ic').click(function(s) { if($(s.target).hasClass('ic-off')) handleLogin(); else { handleLogout(); } false; }); }
n/a
function onOAuthComplete(token, OAuthSchemeKey) { if(token) { if(token.error) { var checkbox = $('input[type=checkbox],.secured') checkbox.each(function(pos){ checkbox[pos].checked = false; }); alert(token.error); } else { var b = token[window.swaggerUi.tokenName]; if (!OAuthSchemeKey){ OAuthSchemeKey = token.state; } if(b){ // if all roles are satisfied var o = null; $.each($('.auth .api-ic .api_information_panel'), function(k, v) { var children = v; if(children && children.childNodes) { var requiredScopes = []; $.each((children.childNodes), function (k1, v1){ var inner = v1.innerHTML; if(inner) requiredScopes.push(inner); }); var diff = []; for(var i=0; i < requiredScopes.length; i++) { var s = requiredScopes[i]; if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) { diff.push(s); } } if(diff.length > 0){ o = v.parentNode.parentNode; $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); // sorry, not all scopes are satisfied $(o).find('.api-ic').addClass('ic-warning'); $(o).find('.api-ic').removeClass('ic-error'); } else { o = v.parentNode.parentNode; $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); // all scopes are satisfied $(o).find('.api-ic').addClass('ic-info'); $(o).find('.api-ic').removeClass('ic-warning'); $(o).find('.api-ic').removeClass('ic-error'); } } }); window.swaggerUi.api.clientAuthorizations.add(window.OAuthSchemeKey, new SwaggerClient.ApiKeyAuthorization('Authorization ', 'Bearer ' + b, 'header')); window.swaggerUi.load(); } } } }
n/a
function processOAuthCode(data) { var OAuthSchemeKey = data.state; // redirect_uri is required in auth code flow // see https://tools.ietf.org/html/draft-ietf-oauth-v2-31#section-4.1.3 var host = window.location; var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; var params = { 'client_id': clientId, 'code': data.code, 'grant_type': 'authorization_code', 'redirect_uri': redirectUrl }; if (clientSecret) { params.client_secret = clientSecret; } $.ajax( { url : window.swaggerUi.tokenUrl, type: "POST", data: params, success:function(data, textStatus, jqXHR) { onOAuthComplete(data, OAuthSchemeKey); }, error: function(jqXHR, textStatus, errorThrown) { onOAuthComplete(""); } }); }
n/a
function(resource) { var resource = Docs.escapeResourceName(resource); if (resource == '') { $('.resource ul.endpoints').slideUp(); return; } $('li#resource_' + resource).removeClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); elem.slideUp(); }
n/a
function(elem) { elem.slideUp(); }
n/a
function(resource) { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); if (resource == '') { $('.resource ul.endpoints li.operation div.content').slideUp(); return; } $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { Docs.collapseOperation($(this)); }); }
n/a
function(resource) { return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); }
n/a
function(resource) { var resource = Docs.escapeResourceName(resource); if (resource == '') { $('.resource ul.endpoints').slideDown(); return; } $('li#resource_' + resource).addClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); elem.slideDown(); }
n/a
function(elem) { elem.slideDown(); }
n/a
function(resource) { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); if (resource == '') { $('.resource ul.endpoints li.operation div.content').slideDown(); return; } $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { Docs.expandOperation($(this)); }); }
n/a
function() { // If shebang has an operation nickname in it.. // e.g. /docs/#!/words/get_search var fragments = $.param.fragment().split('/'); fragments.shift(); // get rid of the bang switch (fragments.length) { case 1: if (fragments[0].length > 0) { // prevent matching "#/" // Expand all operations for the resource and scroll to it var dom_id = 'resource_' + fragments[0]; Docs.expandEndpointListForResource(fragments[0]); $("#"+dom_id).slideto({highlight: false}); } break; case 2: // Refer to the endpoint DOM element, e.g. #words_get_search // Expand Resource Docs.expandEndpointListForResource(fragments[0]); $("#"+dom_id).slideto({highlight: false}); // Expand operation var li_dom_id = fragments.join('_'); var li_content_dom_id = li_dom_id + "_content"; Docs.expandOperation($('#'+li_content_dom_id)); $('#'+li_dom_id).slideto({highlight: false}); break; } }
n/a
function(resource) { var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); if (elem.is(':visible')) { $.bbq.pushState('#/', 2); Docs.collapseEndpointListForResource(resource); } else { $.bbq.pushState('#/' + resource, 2); Docs.expandEndpointListForResource(resource); } }
n/a
SwaggerClient = function (url, options) { helpers.log('This is deprecated, use "new SwaggerClient" instead.'); return new SwaggerClient(url, options); }
n/a
ApiKeyAuthorization = function (name, value, type) { this.name = name; this.value = value; this.type = type; }
n/a
CookieAuthorization = function (cookie) { this.cookie = cookie; }
n/a
PasswordAuthorization = function (username, password) { if (arguments.length === 3) { helpers.log('PasswordAuthorization: the \'name\' argument has been removed, pass only username and password'); username = arguments[1]; password = arguments[2]; } this.username = username; this.password = password; }
n/a
SwaggerApi = function (url, options) { helpers.log('This is deprecated, use "new SwaggerClient" instead.'); return new SwaggerClient(url, options); }
n/a
apply = function (obj) { if (this.type === 'query') { // see if already applied. If so, don't do it again var qp; if (obj.url.indexOf('?') > 0) { qp = obj.url.substring(obj.url.indexOf('?') + 1); var parts = qp.split('&'); if(parts && parts.length > 0) { for(var i = 0; i < parts.length; i++) { var kv = parts[i].split('='); if(kv && kv.length > 0) { if (kv[0] === this.name) { // skip it return false; } } } } } if (obj.url.indexOf('?') > 0) { obj.url = obj.url + '&' + this.name + '=' + this.value; } else { obj.url = obj.url + '?' + this.name + '=' + this.value; } return true; } else if (this.type === 'header') { if(typeof obj.headers[this.name] === 'undefined') { obj.headers[this.name] = this.value; } return true; } }
...
showRequestHeaders: false
});
window.swaggerUi.load();
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
});
</script>
</head>
<body class="swagger-section">
...
apply = function (obj) { obj.cookieJar = obj.cookieJar || new CookieJar(); obj.cookieJar.setCookie(this.cookie); return true; }
...
showRequestHeaders: false
});
window.swaggerUi.load();
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
});
</script>
</head>
<body class="swagger-section">
...
apply = function (obj) { if(typeof obj.headers.Authorization === 'undefined') { obj.headers.Authorization = 'Basic ' + btoa(this.username + ':' + this.password); } return true; }
...
showRequestHeaders: false
});
window.swaggerUi.load();
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
});
</script>
</head>
<body class="swagger-section">
...
build = function (mock) { if (this.isBuilt) { return this; } var self = this; if (this.spec) { this.progress('fetching resource list; Please wait.'); } else { this.progress('fetching resource list: ' + this.url + '; Please wait.'); } var obj = { useJQuery: this.useJQuery, jqueryAjaxCache: this.jqueryAjaxCache, url: this.url, method: 'get', headers: { accept: this.swaggerRequestHeaders }, on: { error: function (response) { if (self.url.substring(0, 4) !== 'http') { return self.fail('Please specify the protocol for ' + self.url); } else if (response.status === 0) { return self.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.'); } else if (response.status === 404) { return self.fail('Can\'t read swagger JSON from ' + self.url); } else { return self.fail(response.status + ' : ' + response.statusText + ' ' + self.url); } }, response: function (resp) { var responseObj = resp.obj; if(!responseObj) { return self.fail('failed to parse JSON/YAML response'); } self.swaggerVersion = responseObj.swaggerVersion; self.swaggerObject = responseObj; if (responseObj.swagger && parseInt(responseObj.swagger) === 2) { self.swaggerVersion = responseObj.swagger; new Resolver().resolve(responseObj, self.url, self.buildFromSpec, self); self.isValid = true; } else { var converter = new SwaggerSpecConverter(); self.oldSwaggerObject = self.swaggerObject; converter.setDocumentationLocation(self.url); converter.convert(responseObj, self.clientAuthorizations, self.options, function(spec) { self.swaggerObject = spec; new Resolver().resolve(spec, self.url, self.buildFromSpec, self); self.isValid = true; }); } } } }; if (this.spec) { self.swaggerObject = this.spec; setTimeout(function () { new Resolver().resolve(self.spec, self.url, self.buildFromSpec, self); }, 10); } else { this.clientAuthorizations.apply(obj); if (mock) { return obj; } new SwaggerHttp().execute(obj, this.options); } return (this.usePromise) ? this.deferredClient.promise : this; }
n/a
buildFromSpec = function (response) { if (this.isBuilt) { return this; } this.apis = {}; this.apisArray = []; this.basePath = response.basePath || ''; this.consumes = response.consumes; this.host = response.host || ''; this.info = response.info || {}; this.produces = response.produces; this.schemes = response.schemes || []; this.securityDefinitions = response.securityDefinitions; this.security = response.security; this.title = response.title || ''; if (response.externalDocs) { this.externalDocs = response.externalDocs; } // legacy support this.authSchemes = response.securityDefinitions; var definedTags = {}; var k; if (Array.isArray(response.tags)) { definedTags = {}; for (k = 0; k < response.tags.length; k++) { var t = response.tags[k]; definedTags[t.name] = t; } } var location; if (typeof this.url === 'string') { location = this.parseUri(this.url); if (typeof this.scheme === 'undefined' && typeof this.schemes === 'undefined' || this.schemes.length === 0) { this.scheme = location.scheme || 'http'; } else if (typeof this.scheme === 'undefined') { this.scheme = this.schemes[0] || location.scheme; } if (typeof this.host === 'undefined' || this.host === '') { this.host = location.host; if (location.port) { this.host = this.host + ':' + location.port; } } } else { if (typeof this.schemes === 'undefined' || this.schemes.length === 0) { this.scheme = 'http'; } else if (typeof this.scheme === 'undefined') { this.scheme = this.schemes[0]; } } this.definitions = response.definitions; var key; for (key in this.definitions) { var model = new Model(key, this.definitions[key], this.models, this.modelPropertyMacro); if (model) { this.models[key] = model; } } // get paths, create functions for each operationId var self = this; // Bind help to 'client.apis' self.apis.help = _.bind(self.help, self); _.forEach(response.paths, function (pathObj, path) { // Only process a path if it's an object if (!_.isPlainObject(pathObj)) { return; } _.forEach(supportedOperationMethods, function (method) { var operation = pathObj[method]; if (_.isUndefined(operation)) { // Operation does not exist return; } else if (!_.isPlainObject(operation)) { // Operation exists but it is not an Operation Object. Since this is invalid, log it. helpers.log('The \'' + method + '\' operation for \'' + path + '\' path is not an Operation Object'); return; } var tags = operation.tags; if (_.isUndefined(tags) || !_.isArray(tags) || tags.length === 0) { tags = operation.tags = [ 'default' ]; } var operationId = self.idFromOp(path, method, operation); var operationObject = new Operation(self, operation.scheme, operationId, method, path, operation, self.definitions, self.models, self.clientAuthorizations); // bind self operation's execute command to the api _.forEach(tags, function (tag) { var clientProperty = _.indexOf(reservedClientTags, tag) > -1 ? '_' + tag : tag; var apiProperty = _.indexOf(reservedApiTags, tag) > -1 ? '_' + tag : tag; var operationGroup = self[clientProperty]; if (clientProperty !== tag) { helpers.log('The \'' + tag + '\' tag conflicts with a SwaggerClient function/property name. Use \'client.' + clientProperty + '\' or \'client.apis.' + tag + '\' instead of \'client.' + tag + '\'.'); } if (apiPropert...
n/a
fail = function (message) { if (this.usePromise) { this.deferredClient.reject(message); return this.deferredClient.promise; } else { if (this.failure) { this.failure(message); } else { this.failure(message); } } }
n/a
help = function (dontPrint) { var output = ''; if (this instanceof SwaggerClient) { _.forEach(this.apis, function (api, name) { if (_.isPlainObject(api)) { output += 'operations for the \'' + name + '\' tag\n'; _.forEach(api.operations, function (operation, name) { output += ' * ' + name + ': ' + operation.summary + '\n'; }); } }); } else if (this instanceof OperationGroup || _.isPlainObject(this)) { output += 'operations for the \'' + this.label + '\' tag\n'; _.forEach(this.apis, function (operation, name) { output += ' * ' + name + ': ' + operation.summary + '\n'; }); } if (dontPrint) { return output; } else { helpers.log(output); return output; } }
n/a
idFromOp = function (path, httpMethod, op) { if(!op || !op.operationId) { op = op || {}; op.operationId = httpMethod + '_' + path; } var opId = op.operationId.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|.\/?,\\'""-]/g, '_') || (path.substring(1) + '_' + httpMethod); opId = opId.replace(/((_){2,})/g, '_'); opId = opId.replace(/^(_)*/g, ''); opId = opId.replace(/([_])*$/g, ''); return opId; }
n/a
initialize = function (url, options) { this.models = {}; this.sampleModels = {}; if (typeof url === 'string') { this.url = url; } else if (_.isObject(url)) { options = url; this.url = options.url; } if(this.url && this.url.indexOf('http:') === -1 && this.url.indexOf('https:') === -1) { // no protocol, so we can only use window if it exists if(typeof(window) !== 'undefined' && window && window.location) { this.url = window.location.origin + this.url; } } options = options || {}; this.clientAuthorizations.add(options.authorizations); this.swaggerRequestHeaders = options.swaggerRequestHeaders || 'application/json;charset=utf-8,*/*'; this.defaultSuccessCallback = options.defaultSuccessCallback || null; this.defaultErrorCallback = options.defaultErrorCallback || null; this.modelPropertyMacro = options.modelPropertyMacro || null; this.parameterMacro = options.parameterMacro || null; this.usePromise = options.usePromise || null; if(this.usePromise) { this.deferredClient = Q.defer(); } if (typeof options.success === 'function') { this.success = options.success; } if (options.useJQuery) { this.useJQuery = options.useJQuery; } if (options.jqueryAjaxCache) { this.jqueryAjaxCache = options.jqueryAjaxCache; } if (options.enableCookies) { this.enableCookies = options.enableCookies; } this.options = options || {}; this.supportedSubmitMethods = options.supportedSubmitMethods || []; this.failure = options.failure || function (err) { throw err; }; this.progress = options.progress || function () {}; this.spec = _.cloneDeep(options.spec); // Clone so we do not alter the provided document if (options.scheme) { this.scheme = options.scheme; } if (this.usePromise || typeof options.success === 'function') { this.ready = true; return this.build(); } }
n/a
function(operationId, api) { var count = 0; var name = operationId; // make unique across this operation group while(true) { var matched = false; _.forEach(api.operations, function (operation) { if(operation.nickname === name) { matched = true; } }); if(!matched) { return name; } name = operationId + '_' + count; count ++; } return operationId; }
n/a
parseUri = function (uri) { var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([ 0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/; var parts = urlParseRE.exec(uri); return { scheme: parts[4] ? parts[4].replace(':','') : undefined, host: parts[11], port: parts[12], path: parts[15] }; }
n/a
setBasePath = function (basePath) { this.basePath = basePath; if(this.apis) { _.forEach(this.apis, function(api) { if(api.operations) { _.forEach(api.operations, function(operation) { operation.basePath = basePath; }); } }); } }
n/a
setHost = function (host) { this.host = host; if(this.apis) { _.forEach(this.apis, function(api) { if(api.operations) { _.forEach(api.operations, function(operation) { operation.host = host; }); } }); } }
n/a
setSchemes = function (schemes) { this.schemes = schemes; if(schemes && schemes.length > 0) { if(this.apis) { _.forEach(this.apis, function (api) { if (api.operations) { _.forEach(api.operations, function (operation) { operation.scheme = schemes[0]; }); } }); } } }
n/a
tagFromLabel = function (label) { return label; }
n/a
function(base, url){ if (url.indexOf('/') === 0) { var parts = base.split('/'); base = parts[0] + '//' + parts[2]; return base + url; } else { var endOfPath = base.length; if (base.indexOf('?') > -1){ endOfPath = Math.min(endOfPath, base.indexOf('?')); } if (base.indexOf('#') > -1){ endOfPath = Math.min(endOfPath, base.indexOf('#')); } base = base.substring(0, endOfPath); if (base.indexOf('/', base.length - 1 ) !== -1){ return base + url; } return base + '/' + url; } }
n/a
function(){ Docs.collapseEndpointListForResource(''); }
n/a
function(){ Docs.expandOperationsForResource(''); }
n/a
function(option) { return this.options[option]; }
n/a
function(options) { options = options || {}; if (options.defaultModelRendering !== 'model') { options.defaultModelRendering = 'schema'; } if (!options.highlightSizeThreshold) { options.highlightSizeThreshold = 100000; } // Allow dom_id to be overridden if (options.dom_id) { this.dom_id = options.dom_id; delete options.dom_id; } if (!options.supportedSubmitMethods){ options.supportedSubmitMethods = [ 'get', 'put', 'post', 'delete', 'head', 'options', 'patch' ]; } if (typeof options.oauth2RedirectUrl === 'string') { window.oAuthRedirectUrl = options.oauth2RedirectUrl; } // Create an empty div which contains the dom_id if (! $('#' + this.dom_id).length){ $('body').append('<div id="' + this.dom_id + '"></div>') ; } this.options = options; // set marked options marked.setOptions({gfm: true}); // Set the callbacks var that = this; this.options.success = function() { return that.render(); }; this.options.progress = function(d) { return that.showMessage(d); }; this.options.failure = function(d) { return that.onLoadFailure(d); }; // Create view to handle the header inputs this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')}); // Event handler for when the baseUrl/apiKey is entered by user this.headerView.on('update-swagger-ui', function(data) { return that.updateSwaggerUi(data); }); // JSon Editor custom theming JSONEditor.defaults.iconlibs.swagger = JSONEditor.AbstractIconLib.extend({ mapping: { collapse: 'collapse', expand: 'expand' }, icon_prefix: 'swagger-' }); }
n/a
function(){ Docs.collapseOperationsForResource(''); }
n/a
function(){ // Initialize the API object if (this.mainView) { this.mainView.clear(); } if (this.authView) { this.authView.remove(); } var url = this.options.url; if (url && url.indexOf('http') !== 0) { url = this.buildUrl(window.location.href.toString(), url); } if(this.api) { this.options.authorizations = this.api.clientAuthorizations.authz; } this.options.url = url; this.headerView.update(url); this.api = new SwaggerClient(this.options); }
...
},
docExpansion: "none",
jsonEditor: false,
defaultModelRendering: 'schema',
showRequestHeaders: false
});
window.swaggerUi.load();
function log() {
if ('console' in window) {
console.log.apply(console, arguments);
}
}
});
...
function(data){ if (data === undefined) { data = ''; } $('#message-bar').removeClass('message-success'); $('#message-bar').addClass('message-fail'); var val = $('#message-bar').text(data); if (this.options.onFailure) { this.options.onFailure(data); } return val; }
n/a
function(){ var authsModel; this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); this.mainView = new SwaggerUi.Views.MainView({ model: this.api, el: $('#' + this.dom_id), swaggerOptions: this.options, router: this }).render(); if (!_.isEmpty(this.api.securityDefinitions)){ authsModel = _.map(this.api.securityDefinitions, function (auth, name) { var result = {}; result[name] = auth; return result; }); this.authView = new SwaggerUi.Views.AuthButtonView({ data: SwaggerUi.utils.parseSecurityDefinitions(authsModel), router: this }); $('#auth_container').append(this.authView.render().el); } this.showMessage(); switch (this.options.docExpansion) { case 'full': this.expandAll(); break; case 'list': this.listAll(); break; default: break; } this.renderGFM(); if (this.options.onComplete){ this.options.onComplete(this.api, this); } setTimeout(Docs.shebang.bind(this), 100); }
n/a
function(){ $('.markdown').each(function(){ $(this).html(marked($(this).html())); }); $('.propDesc', '.model-signature .description').each(function () { $(this).html(marked($(this).html())).addClass('markdown'); }); }
n/a
function(option, value) { this.options[option] = value; }
n/a
function(data){ if (data === undefined) { data = ''; } var $msgbar = $('#message-bar'); $msgbar.removeClass('message-fail'); $msgbar.addClass('message-success'); $msgbar.text(data); if(window.SwaggerTranslator) { window.SwaggerTranslator.translate($msgbar); } }
n/a
function(data){ this.options.url = data.url; this.load(); }
n/a
function() { warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().'); if (typeof window.swaggerUi === 'undefined') { throw new TypeError('window.swaggerUi is not defined'); } if (window.swaggerUi instanceof SwaggerUi) { window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations, arguments); } }
n/a