Move backward compatibility to swaggerUi.js and warn users about API changes

This commit is contained in:
Mohsen Azimi
2015-03-17 12:09:32 -07:00
parent d61cf24ae0
commit f49c1689d2
4 changed files with 68 additions and 10 deletions

32
dist/swagger-ui.js vendored
View File

@@ -203,6 +203,38 @@ 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);
}
}
})();
this["Handlebars"] = this["Handlebars"] || {};
this["Handlebars"]["templates"] = this["Handlebars"]["templates"] || {};
this["Handlebars"]["templates"]["apikey_button_view"] = Handlebars.template({"compiler":[6,">= 2.0.0-beta.1"],"main":function(depth0,helpers,partials,data) {

File diff suppressed because one or more lines are too long

View File

@@ -83,13 +83,6 @@
console.log.apply(console, arguments);
}
}
// don't break backward compatibility with previous versions
window.authorizations = {
add: swaggerUi.api.clientAuthorizations.add
};
window.ApiKeyAuthorization = SwaggerClient.ApiKeyAuthorization;
window.PasswordAuthorization = SwaggerClient.PasswordAuthorization;
});
</script>
</head>

View File

@@ -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);
}
}
})();