Move backward compatibility to swaggerUi.js and warn users about API changes
This commit is contained in:
@@ -196,3 +196,36 @@ window.SwaggerUi = Backbone.Router.extend({
|
||||
});
|
||||
|
||||
window.SwaggerUi.Views = {};
|
||||
|
||||
// don't break backward compatibility with previous versions and warn users to upgrade their code
|
||||
(function(){
|
||||
window.authorizations = {
|
||||
add: function() {
|
||||
warn('using window.authorizations is depreciated. Please use waggerUi.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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
window.ApiKeyAuthorization = function() {
|
||||
warn('window.ApiKeyAuthorization is depreciated. Please use SwaggerClient.ApiKeyAuthorization.');
|
||||
SwaggerClient.ApiKeyAuthorization.apply(window, arguments);
|
||||
};
|
||||
|
||||
window.PasswordAuthorization = function() {
|
||||
warn('window.PasswordAuthorization is depreciated. Please use SwaggerClient.PasswordAuthorization.');
|
||||
SwaggerClient.PasswordAuthorization.apply(window, arguments);
|
||||
};
|
||||
|
||||
function warn(message) {
|
||||
if ('console' in window && typeof window.console.warn === 'function') {
|
||||
console.warn(message);
|
||||
}
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user