2.x to 3.x Upgrade Notes
If you're using MongoDB
as configuration database run the following script against api_specs
collection:
db.getCollection('api_specs').find({}).forEach(function(doc) {
doc.plugins = [];
var corsMeta = doc.cors_meta || {enabled: false};
doc.plugins.push({
"name": "cors",
"enabled": !!corsMeta.enabled,
"config": corsMeta
});
delete doc.plugins[0].config.enabled;
var rateLimit = doc.rate_limit || {enabled: false, limit: 0};
doc.plugins.push({
"name": "rate_limit",
"enabled": !!rateLimit.enabled,
"config": {
"limit": rateLimit.limit,
"policy": "local"
}
});
doc.plugins.push({
"name": "oauth2",
"enabled": !!doc.use_oauth2,
"config": {"server_name": doc.oauth_server_name || null}
});
doc.plugins.push({
"name": "compression",
"enabled": !!doc.use_compression
});
delete doc.rate_limit;
delete doc.cors_meta;
delete doc.use_oauth2;
delete doc.use_basic_auth;
delete doc.use_compression;
doc.updated_at = new Date();
db.api_specs.update({"_id": doc._id}, doc);
});